custom Matrix class to VC++ standard doubles Matrix class

  • Thread starter Thread starter Manjree Garg
  • Start date Start date
M

Manjree Garg

Hi,

I developed a custom Matrix class derived from custom VC++ doubles Array
class derived from a RealArray which is defined as:

typedef CArray<double,double> RealArray;

Now I need to convert this custom Matrix class to standard doubles Matrix
(VC++) as I am passing it to some function that understands only the standard
class.

Is there some way of doing it?????

Any suggestions are appriciated.

Manj.
 
Manjree said:
Hi,

I developed a custom Matrix class derived from custom VC++ doubles Array
class derived from a RealArray which is defined as:

typedef CArray<double,double> RealArray;

Now I need to convert this custom Matrix class to standard doubles Matrix
(VC++) as I am passing it to some function that understands only the standard
class.

Is there some way of doing it?????

Any suggestions are appriciated.

Manj:

Well, I think that depends on how you have set up your matrix class.

If you look at the Numerical Recipes matrix class (wwww.nr.com) you will
see how they have set it up to that it can be passed as an argument to a
routine expecting a standard two-dimensional array. This is done by
assigning all the memory in a contiguous array, and then defining
pointers into this array to get row-column indexing capability.

Personally, I would not touch CArray with a 10-foot pole. Rather I would
(and do) use either solutions based on std::vector, or a custom solution
such as the Numerical Recipes one.
 
Hi David

Thanks for your reply.

First of all I need to know if there is any standard doubles Matrix class
available in VC++ (VS.NET 2005).

If Yes then how to use it (some link?).

How can I find Numerical Recipes matrix class as the code is not available
at www.nr.com?


Regards,

Manj.
 
Manjree said:
Hi David

Thanks for your reply.

First of all I need to know if there is any standard doubles Matrix class
available in VC++ (VS.NET 2005).

If Yes then how to use it (some link?).

How can I find Numerical Recipes matrix class as the code is not available
at www.nr.com?

Manj:

Yes, the Numerical Recipes web site is rather annoying. The utility
vector and matrix classes are actually public domain (I believe) and may
be found at

http://www.nr.com/codefile.php?nr3

Or, you could do what I just did and put "C++ matrix library" into
Google. You will find lots of hits, including the "Matrix Template
Library" which is based on STL.
 
Hello David

Thanks for the reply but my question still remains the same.

I am passing a doubles data matrix to a Matlab function (using Matlab
builder) via MWNumericArray which accepts standard doubles matrix. All the
links on google are for custom matrix which it doesn't accept. So How can I
resolve this problem?????

Cheers.

Manjree
 
Manjree said:
Hello David

Thanks for the reply but my question still remains the same.

I am passing a doubles data matrix to a Matlab function (using Matlab
builder) via MWNumericArray which accepts standard doubles matrix. All the
links on google are for custom matrix which it doesn't accept. So How can I
resolve this problem?????

Manjree:

Well, if you have a custom matrix class that stores its elements in
contiguous memory (as the Numerical Recipes matrix class does by design)
then &a[0][0] is a pointer to the first element of that storage, and you
can pass it to a routine that expects a standard "C matrix".

Numerical Recipes calls this feature "backdoor compatibility".
 
Back
Top