Connecting Tech Pros Worldwide Help | Site Map

passing and declaring vectors and matrices?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 05:49 AM
sandwich_eater@hotmail.com
Guest
 
Posts: n/a
Default passing and declaring vectors and matrices?

What is the usual way to declare real (float) vectors and matrices?
What ways are there to pass them to them into a function (by ref, by
val, pointer) ?

this is what I have...
const int MAX_MAT_DIM = 200;
typedef double TMTMatrix [MAX_MAT_DIM][MAX_MAT_DIM];
typedef double TMTVector [MAX_MAT_DIM];

void myfunc1(TMTVector &y, TMTMatrix &A);
void myfunc2(TMTVector *y, TMTMatrix *A);

....

TMTMatrix A1, A2;

myfunc1(y, A1);
myfunc2(&y, &A2);

if u is changed in both myfuncs will A1 and A2 change?

Thanks,
Daniel


  #2  
Old July 23rd, 2005, 05:50 AM
Victor Bazarov
Guest
 
Posts: n/a
Default Re: passing and declaring vectors and matrices?

sandwich_eater@hotmail.com wrote:[color=blue]
> What is the usual way to declare real (float) vectors and matrices?
> What ways are there to pass them to them into a function (by ref, by
> val, pointer) ?
>
> this is what I have...
> const int MAX_MAT_DIM = 200;
> typedef double TMTMatrix [MAX_MAT_DIM][MAX_MAT_DIM];
> typedef double TMTVector [MAX_MAT_DIM];
>
> void myfunc1(TMTVector &y, TMTMatrix &A);
> void myfunc2(TMTVector *y, TMTMatrix *A);
>
> ...
>
> TMTMatrix A1, A2;
>
> myfunc1(y, A1);
> myfunc2(&y, &A2);
>
> if u is changed in both myfuncs will A1 and A2 change?[/color]

What is 'y' here? What is 'u'? How can your question be answered
without knowing what the 'mufunc1' and 'myfunc2' do?

V


  #3  
Old July 23rd, 2005, 05:50 AM
sandwich_eater@hotmail.com
Guest
 
Posts: n/a
Default Re: passing and declaring vectors and matrices?

Sorry I meant 'A' not u. I only wrote these functions as examples. My
question is a general one about how to declare and pass vectors upto a
maximum dimension, or open size if that can be done.

Victor Bazarov wrote:[color=blue]
> sandwich_eater@hotmail.com wrote:[color=green]
> > What is the usual way to declare real (float) vectors and matrices?
> > What ways are there to pass them to them into a function (by ref, by
> > val, pointer) ?
> >
> > this is what I have...
> > const int MAX_MAT_DIM = 200;
> > typedef double TMTMatrix [MAX_MAT_DIM][MAX_MAT_DIM];
> > typedef double TMTVector [MAX_MAT_DIM];
> >
> > void myfunc1(TMTVector &y, TMTMatrix &A);
> > void myfunc2(TMTVector *y, TMTMatrix *A);
> >
> > ...
> >
> > TMTMatrix A1, A2;
> >
> > myfunc1(y, A1);
> > myfunc2(&y, &A2);
> >
> > if u is changed in both myfuncs will A1 and A2 change?[/color]
>
> What is 'y' here? What is 'u'? How can your question be answered
> without knowing what the 'mufunc1' and 'myfunc2' do?
>
> V[/color]

  #4  
Old July 23rd, 2005, 05:50 AM
velthuijsen@hotmail.com
Guest
 
Posts: n/a
Default Re: passing and declaring vectors and matrices?

sandwich_eater@hotmail.com wrote:[color=blue]
> What is the usual way to declare real (float) vectors and matrices?
> What ways are there to pass them to them into a function (by ref, by
> val, pointer) ?[/color]

Try std::vector<float> and std::vector<std::vector<float> >.
Then use pass by reference for passing them to functions.

[SNIP][color=blue]
> if A is changed in both myfuncs will A1 and A2 change?[/color]

Depends on what you mean by change but generally yes.

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.