469,904 Members | 2,288 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,904 developers. It's quick & easy.

custom Matrix class to VC++ standard doubles Matrix class

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,doubleRealArray;

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.
Dec 20 '07 #1
5 2521
Manjree Garg wrote:
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,doubleRealArray;

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.

--
David Wilkinson
Visual C++ MVP
Dec 20 '07 #2
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.

"David Wilkinson" wrote:
Manjree Garg wrote:
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,doubleRealArray;

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.

--
David Wilkinson
Visual C++ MVP
Dec 20 '07 #3
Manjree Garg wrote:
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.

--
David Wilkinson
Visual C++ MVP
Dec 20 '07 #4
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

"David Wilkinson" wrote:
Manjree Garg wrote:
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.

--
David Wilkinson
Visual C++ MVP
Dec 21 '07 #5
Manjree Garg wrote:
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".

--
David Wilkinson
Visual C++ MVP
Dec 21 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Erik Borgstr?m | last post: by
3 posts views Thread by Dave | last post: by
6 posts views Thread by memocan | last post: by
2 posts views Thread by 50295 | last post: by
1 post views Thread by Tamas Demjen | last post: by
16 posts views Thread by Martin Jørgensen | last post: by
20 posts views Thread by Frank-O | last post: by
2 posts views Thread by sarah | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.