PC Review


Reply
Thread Tools Rate Thread

custom Matrix class to VC++ standard doubles Matrix class

 
 
Manjree Garg
Guest
Posts: n/a
 
      20th Dec 2007
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.
 
Reply With Quote
 
 
 
 
David Wilkinson
Guest
Posts: n/a
 
      20th Dec 2007
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,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.

--
David Wilkinson
Visual C++ MVP
 
Reply With Quote
 
Manjree Garg
Guest
Posts: n/a
 
      20th Dec 2007
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,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.
>
> --
> David Wilkinson
> Visual C++ MVP
>

 
Reply With Quote
 
David Wilkinson
Guest
Posts: n/a
 
      20th Dec 2007
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
 
Reply With Quote
 
Manjree Garg
Guest
Posts: n/a
 
      21st Dec 2007
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
>

 
Reply With Quote
 
David Wilkinson
Guest
Posts: n/a
 
      21st Dec 2007
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Matrix Class =?Utf-8?B?QWxmb25zbyBQYXJlZGVz?= Microsoft Dot NET Compact Framework 0 4th Apr 2005 09:21 PM
VBA Matrix class R Avery Microsoft Excel Programming 12 11th Aug 2004 05:41 AM
Matrix class in .NET Compact Framwork =?Utf-8?B?UGF0cmljaw==?= Microsoft Dot NET Compact Framework 1 16th Jul 2004 03:14 PM
Matrix class hattori3 Microsoft C# .NET 0 10th Jan 2004 10:55 AM
Matrix class hattori3 Microsoft C# .NET 0 10th Jan 2004 10:53 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:29 AM.