Converting Fortran 90 array access to use Matrix?

"Reich, Darrell" <[email protected]>
Newsgroups gmane.comp.lib.boost.ublas
Message-ID <56A4B6DB41508E44B3E3BE1603D25BCF03C14ADF@0461-its-exmb01.us.saic.com>
What is the most efficient way to convert Fortran's column array access
like shown below to C++?

a(i,:) = 0 ! set entire column to zero

 

I suspect best solution might use matrix proxies like matrix_row?

Can this be done on one line without the for loop?

Can you help me fix the syntax on the commented out code that attempted
to use iterators?

 

#include "boost/numeric/ublas/matrix.hpp"

#include "boost/numeric/ublas/matrix_proxy.hpp"

#include "boost/numeric/ublas/io.hpp"

 

int main()

{

   const int N = 3;

   boost::numeric::ublas::matrix<double> M(N,N,1.0);

 
boost::numeric::ublas::matrix_row<boost::numeric::ublas::matrix<double>
> row1(M,1);

   //??std::vector<boost::numeric::ublas::matrix<double>*>::iterator
mit;

 

   //??how to set the matrix row to zero on one line like Fortran 90
a(1,:)=0.0

   //for (mit = row1.begin(); mit != row1.end(); ++mit)

   //for_each(row1.begin(), row1.end(), [] (const std::unique_ptr<??>&
ptr)

   for (int i = 0; i < row1.size(); ++i) // not i++

      row1(i) = 0.0;

 

   std::cout << "row = " << row1 << std::endl;

   std::cout << "Matrix = " << M << std::endl;

 

   return N;

}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.