MTL strip matrix multiplication

xiaoxiao2021-03-06  42

// MTL strip matrix multiplication

// Solving by Robinkin //

#include #include "mtrix.h" #include "mtl / mtl.h" #include "mtl / utils.h" #include "mtl / tinalg_vec.h"

/ *

Sample Output

Array a in packed form [[1, 1, 1,], [2, 2, 2,], [3, 3, 3,], [4, 4, 4,], [5,],] x [1, 2, 3, 4, 5,] y [1, 1, 1, 1, 1,] AX Y [15, 39, 75, 75, 53,]

* /

Using namespace MTL;

Typedef Matrix :: type matrix; type> vector;

INTMAIN () {const INT m = 5; const INT n = 5; Matrix A (M, N, 0, 2);

Vector x (n); vector y (m);

// 1 1 1 1 1 // // 2 2 2 2 1 // // a = 3 3 3 x = 3 y = 1 //// 4 4 4 1 // // 5 5 1

INT row = 1; // Assignment Matrix :: item t = a.begin (); while (ri! = a.end ()) {matrix :: row :: item i = (* ri) .begin (); While (i! = (* ri) .end ()) {* i = row; i;} row; ri;}

For (int i = 0; i

MTL :: Set_Value (Y, 1);

Std :: cout << "array a in packed form" << std :: endl; print_row (a);

Std :: cout << "x" << std :: endl; print_vector (x); std :: cout << "y" << std :: endl; print1;

// y = 2 * x * a 3 * y Mult (A, scaled (x, 2), scaled (y, 3), y);

Std :: cout << "AX Y" << std :: endl; print_vector (y);

Return 0;}

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

New Post(0)