MTL matrix transposition

xiaoxiao2021-03-06  14

// Robinkin organizes

#include #include #include using namespace MTL;

// The element is Double, the shape is a rectangle (also symmetry, upper triangle, lower triangle, strip matrix, etc.), the element is close (not sparse, not compressed),

// Lord (can you still prior

Typedef Matrix , Dense <>, Column_major> :: Type Matrix

// element compression storage TypedEf Matrix , compressed <>, column_major> :: Type Matrix1;

// Matrix element is int, Rectangle <>, Dense <>, column_major> :: Type Matrix2;

INTMAIN (int, char * []) ​​{Matrix A (3, 5), B (5, 3); Matrix1 A1 (3, 5), B1 (5, 3); Matrix2 A2 (3, 5), B2 ( 5, 3); for (int J = 0; J <5; J) for (int i = 0; i <3; i) {A (i, j) = i * 5 j; A1 (i, j) = i * 5 j; A2 (i, j) = i * 5 j;}

// The result is the same

Transpose (A, B); Transpose (A1, B1); Transpose (A2, B2); Print_all_matrix (a); print_all_matrix (b);

Std :: cout << std :: endl; print_all_matrix (a1); print_all_matrix (b1);

Std :: cout << std :: endl; print_all_matrix (a2); print_all_matrix (b2); exit (0);

转载请注明原文地址:https://www.9cbs.com/read-49301.html

New Post(0)