boost ublas matrix initialisation
From
Single Stage to Orbit@21:1/5 to
All on Fri Jan 10 22:46:35 2025
I've been playing with ublas and matrices in Boost.
Here's some code:
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
using namespace boost::numeric::ublas;
int main()
{
vector<double> x(2);
x[0] = 1; x[1] = 2;
matrix<double> A (2, 2);
A(0, 0) = 0; A(0, 1) = 1;
A(1, 0) = 2; A(1, 1) = 3;
vector<double> y = prod(A, x);
std::cout << y << std::endl;
return 0;
}
I've googled but there seems to be no sane way to initialise the
matrix<double> constructor with a initalisation list?
Something like:
matrix<double> A(2,2) = { {0, 1}, {2, 3}};
looks much neater rather than the code in the example above.
Any suggestions?
matrix<double, 2, 2> A { { 0, 1}, {2, 3}};
That looks much tidier.
Thanks.
--
Tactical Nuclear Kittens
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)