Rate This Document
Findability
Accuracy
Completeness
Readability

?lacpy

Copy all or some elements of matrix A to matrix B.

Interface Definition

C interface:

slacpy_(const char *uplo, const int *m, const int *n, const float *a, const int *lda, float *b, const int *ldb);

dlacpy_(const char *uplo, const int *m, const int *n, const double *a, const int *lda, double *b, const int *ldb);

clacpy_(const char *uplo, const int *m, const int *n, const float _Complex *a, const int *lda, float _Complex *b, const int *ldb);

zlacpy_(const char *uplo, const int *m, const int *n, const double _Complex *a, const int *lda, double _Complex *b, const int *ldb);

Fortran interface:

SLACPY(UPLO, M, N, A, LDA, B, LDB);

DLACPY(UPLO, M, N, A, LDA, B, LDB);

CLACPY(UPLO, M, N, A, LDA, B, LDB);

ZLACPY(UPLO, M, N, A, LDA, B, LDB);

Parameters

Parameter

Type

Description

Input/Output

uplo

Character

  • 'U': Copies the upper triangular part of matrix A.
  • 'L': Copies the lower triangular part of matrix A.
  • Other values: Copies all elements of matrix A.

Input

m

Integer

Number of rows in matrix A. m ≥ 0.

Input

n

Integer

Number of columns in matrix A, n ≥ 0.

Input

a

  • A single-precision floating-point array for slacpy
  • A double-precision floating-point array for dlacpy
  • A complex single-precision array for clacpy
  • A complex double-precision array for zlacpy

Array with a size of lda*n.

  • If uplo='U', only the upper triangle or trapezoid is accessed.
  • If uplo='L', only the lower triangle or trapezoid is accessed.

Input

lda

Integer

Leading dimension of matrix A. lda ≥ max(1, m).

Input

b

  • A single-precision floating-point array for slacpy
  • A double-precision floating-point array for dlacpy
  • A complex single-precision array for clacpy
  • A complex double-precision array for zlacpy

Array with a size of ldb*n.

On exit, matrix B = matrix A in the locations specified by uplo.

Output

ldb

Integer

Leading dimension of matrix B. ldb ≥ max(1, m).

Input

Dependency

#include "klapack.h"

Examples

C interface:

const char uplo = 'F';
const int m = 4;
const int n = 4;
const int lda = 4;
const int ldb = 4;

double a[] = { 1.0, 1.0, 1.0, 1.0,
               2.0, 2.0, 2.0, 2.0,
               8.0, 3.0, 3.0, 3.0,
               4.0, 4.0, 4.0, 4.0};
double *b = (double*)malloc(lda * n * sizeof(double));

dlacpy_(&uplo, &m, &n, a, &lda, b, &ldb);

/* output */
* b
* 1.000000        2.000000        8.000000        4.000000
* 1.000000        2.000000        3.000000        4.000000
* 1.000000        2.000000        3.000000        4.000000
* 1.000000        2.000000        3.000000        4.000000

Fortran interface:

CHARACTER :: uplo = "F"
PARAMETER (n = 4) 
PARAMETER (m = 4) 
PARAMETER (lda = 4)
PARAMETER (ldb = 4)
REAL(8) :: a(lda, n)  
REAL(8) :: b(ldb, n)
  
DATA a / 1.0, 1.0, 1.0, 1.0,
$        2.0, 2.0, 2.0, 2.0,
$        8.0, 3.0, 3.0, 3.0,
$        4.0, 4.0, 4.0, 4.0 /
 EXTERNAL DLACPY
 CALL DLACPY(uplo, m, n, a, lda, b, ldb);
* 
* Output: 
* a output (stored in column-major)
* 1.000000        2.000000        8.000000        4.000000
* 1.000000        2.000000        3.000000        4.000000
* 1.000000        2.000000        3.000000        4.000000
* 1.000000        2.000000        3.000000        4.000000