Arrays in .NET (cli)

Z

Zoran Stipanicev

I have c++ code, showed below, for allocating lower triangular matrix
and I have to write that in .NET (cli). I can't use 1D array because
I want to use property [,] with 2D notation (like LowerTriM[r,c]).
This works fine in native c++ but I have no idea how to do it in cli.
Any suggestions?


typedef float Type;

Type **conteiner_;
//alocate row pointers
conteiner_ = new Type*[r]

//alocate lower triangular matrix
conteiner_[0] = new Type[(r*(r+1))/2];

//set row pointers
for(int i = 1; i < row_; ++i )
{
conteiner_ = conteiner_[i-1] + i;
}

Thx!

Best regards,
Zoran Stipanicev
 
P

Peter Oliphant

Something like this:

typedef array<Type> Type_Array ;

Type_Array^ conteiner_ = gcnew Type_Array(r) ;

[==P==]
 
P

Peter Oliphant

Oh, for 2D stuff it's like this I think:

typedef array<Type,2> Type_Array_2D ;

Type_Array_2D^ array_2d = gcnew Type_Array_2D(r,c) ;

array_2d[0,0] = Type(0) ;

[==P==]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top