473,395 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 2784
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Erik Borgstr?m | last post by:
Hi, I simply want to use simple matrices of ints or doubles in C++ and I want all the good: 1) be able to use double-index, e.g. m 2) not have to use pointers at all 3) do it fast I know...
3
by: Dave | last post by:
Hi there: i am doing a matrix class for practice. everything is ok except the operator. Basically, i want to achieve the same way as the normal double's, such as: m = 4.0; m = m + m;...
6
by: memocan | last post by:
#include <iostream> using namespace std; int x; //global variable matrix int main() { x= new float ; //initialize the size now }
2
by: 50295 | last post by:
Hi - I program in C++ but I'm not good with VC++ (yet). I will like to create a custom project for which a specific template or wizard does not exist. Because the program is a console...
1
by: Tamas Demjen | last post by:
I started to experiment with VC++ 2005 Beta1. So far everything went fine, and already have a working project, but soon I realized that the compiler was ancient (not supporting half of the C++/CLI...
16
by: Martin Jørgensen | last post by:
Hi, I've made a program from numerical recipes. Looks like I'm not allowed to distribute the source code from numerical recipes but it shouldn't even be necessary to do that. My problem is...
8
by: MVM | last post by:
I am new to VS 2003. I did programming in vb6 and vc6, but not through studio. I am having lot of confusion on how to start, where to start? I like to write a program in vc++ under vs 2003. i...
20
by: Frank-O | last post by:
Hi , Recently I have been commited to the task of "translating" some complex statistical algorithms from Matlab to C++. The goal is to be three times as fast as matlab ( the latest) . I've...
2
by: sarah | last post by:
hi all I'm trying to program a c++ matrix. can anybody help me? how can i attach the file to be programmed with this post? sarah
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.