vector - How should I multiply two matrices in C++? -


note: i'm using standard library c++, , storing matrices multidimensional vectors (see example below).

i'm having trouble finding proper function multiply 2 matrices in c++. clarify i'm trying do:

a = | a1 a2 |  b = | b1 |     | a3 a4 |      | b2 |  result = | (a1 * b1 + a2 * b2) |          | (a3 * b1 + a4 * b2) | 

obviously using simple algorithm i'm trying find if there's function this.

my specific example in c++:

#include <vector>  std::vector<std::vector<double>> a; a.push_back({ 0.96, 0.56 }); a.push_back({ 0.01, 0.41 });  std::vector<std::vector<double>> b; b.push_back({ 1.331749 }); b.push_back({ 1.0440705 });  result = (a * b); 

where "result" be:

| 1.8631586 | | 0.4413864 | 

how should go doing above?

no, there no functions in c++ library vector multiplication. there building blocks, std::for_each, std::copy, , std::transform, can used implement them, it's implement complete algorithm yourself.

there might libraries floating around, somewhere on intertubes, implement these algorithms. can try luck google.


Comments

Popular posts from this blog

c# - Class in a list -

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -