@@ -188,21 +188,66 @@ console.log( ndarray2array( B, shape, strides, 0, order ) );
188
188
### Usage
189
189
190
190
``` c
191
- TODO
191
+ # include " stdlib/lapack/base/dlacpy.h "
192
192
```
193
193
194
- #### TODO
194
+ #### c_dlacpy( layout, uplo, M, N, \* A, LDA, \* B, LDB )
195
195
196
- TODO .
196
+ Copies all or part of a matrix ` A ` to another matrix ` B ` .
197
197
198
198
``` c
199
- TODO
199
+ #include " stdlib/lapack/base/shared.h"
200
+
201
+ const double A[] = { 1.0, 2.0, 3.0, 4.0 };
202
+ double B[ ] = { 0.0, 0.0, 0.0, 0.0 };
203
+
204
+ c_dlacpy ( LAPACK_ROW_MAJOR, LAPACK_UPPER_TRIANGLE, 2, 2, A, 2, B, 2 );
200
205
```
201
206
202
- TODO
207
+ The function accepts the following arguments:
208
+
209
+ - **order**: `[in] LAPACK_LAYOUT` storage layout.
210
+ - **uplo**: `[in] int` specifies whether to copy the upper or lower triangular/trapezoidal part of a matrix `A`.
211
+ - **M**: `[in] LAPACK_INT` number of rows in `A`.
212
+ - **N**: `[in] LAPACK_INT` number of columns in `A`.
213
+ - **A**: `[in] double*` input matrix.
214
+ - **LDA**: `[in] LAPACK_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`).
215
+ - **B**: `[out] double*` output matrix.
216
+ - **LDB**: `[in] LAPACK_INT` stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`).
217
+
218
+ ```c
219
+ LAPACK_INT c_dlacpy( const LAPACK_LAYOUT layout, const int uplo, const LAPACK_INT M, const LAPACK_INT N, const double *A, const LAPACK_INT LDA, double *B, const LAPACK_INT LDB );
220
+ ```
221
+
222
+ #### c_dlacpy_ndarray( uplo, M, N, \* A, sa1, sa2, oa, \* B, sb1, sb2, ob )
223
+
224
+ Copies all or part of a matrix ` A ` to another matrix ` B ` using alternative indexing semantics.
225
+
226
+ ``` c
227
+ #include " stdlib/lapack/base/shared.h"
228
+
229
+ const double A[] = { 1.0, 2.0, 3.0, 4.0 };
230
+ double B[ ] = { 0.0, 0.0, 0.0, 0.0 };
231
+
232
+ c_dlacpy_ndarray ( LAPACK_UPPER_TRIANGLE, 2, 2, A, 2, 1, 0, B, 2, 1, 0 );
233
+ ```
234
+
235
+ The function accepts the following arguments:
236
+
237
+ - **uplo**: `[in] int` specifies whether to copy the upper or lower triangular/trapezoidal part of a matrix `A`.
238
+ - **M**: `[in] LAPACK_INT` number of rows in `A`.
239
+ - **N**: `[in] LAPACK_INT` number of columns in `A`.
240
+ - **A**: `[in] double*` input matrix.
241
+ - **sa1**: `[in] LAPACK_INT` stride of the first dimension of `A`.
242
+ - **sa2**: `[in] LAPACK_INT` stride of the second dimension of `A`.
243
+ - **oa**: `[in] LAPACK_INT` starting index for `A`.
244
+ - **B**: `[out] double*` output matrix.
245
+ - **sb1**: `[in] LAPACK_INT` stride of the first dimension of `B`.
246
+ - **sb2**: `[in] LAPACK_INT` stride of the second dimension of `B`.
247
+ - **ob**: `[in] LAPACK_INT` starting index for `B`.
203
248
204
249
```c
205
- TODO
250
+ LAPACK_INT c_dlacpy_ndarray( const int uplo, const LAPACK_INT M, const LAPACK_INT N, const double *A, const LAPACK_INT strideA1, const LAPACK_INT strideA2, const LAPACK_INT offsetA, double *B, const LAPACK_INT strideB1, const LAPACK_INT strideB2, const LAPACK_INT offsetB );
206
251
```
207
252
208
253
</section >
@@ -224,7 +269,49 @@ TODO
224
269
### Examples
225
270
226
271
``` c
227
- TODO
272
+ #include " stdlib/lapack/base/dlacpy.h"
273
+ #include " stdlib/lapack/base/shared.h"
274
+ #include < stdio.h>
275
+
276
+ int main ( void ) {
277
+ // Define a 3x3 input matrix stored in row-major order:
278
+ const double A[ 3* 3 ] = {
279
+ 1.0, 2.0, 3.0,
280
+ 4.0, 5.0, 6.0,
281
+ 7.0, 8.0, 9.0
282
+ };
283
+
284
+ // Define a 3x3 output matrix:
285
+ double B[ 3*3 ] = {
286
+ 0.0, 0.0, 0.0,
287
+ 0.0, 0.0, 0.0,
288
+ 0.0, 0.0, 0.0
289
+ };
290
+
291
+ // Specify the number of elements along each dimension of `A`:
292
+ const int M = 3;
293
+ const int N = 3;
294
+
295
+ // Copy elements from the upper triangle of `A` to `B`:
296
+ c_dlacpy( LAPACK_ROW_MAJOR, LAPACK_UPPER_TRIANGLE, M, N, A, N, B, N );
297
+
298
+ // Print the result:
299
+ for ( int i = 0; i < M; i++ ) {
300
+ for ( int j = 0; j < N; j++ ) {
301
+ printf( "B[ %i, %i ] = %lf\n", i, j, B[ (i*N)+j ] );
302
+ }
303
+ }
304
+
305
+ // Copy elements from the lower triangle of `A` to `B` using alternative indexing semantics:
306
+ c_dlacpy_ndarray( LAPACK_LOWER_TRIANGLE, M, N, A, N, 1, 0, B, N, 1, 0 );
307
+
308
+ // Print the result:
309
+ for ( int i = 0; i < M; i++ ) {
310
+ for ( int j = 0; j < N; j++ ) {
311
+ printf( "B[ %i, %i ] = %lf\n", i, j, B[ (i*N)+j ] );
312
+ }
313
+ }
314
+ }
228
315
```
229
316
230
317
</section>
0 commit comments