473,398 Members | 2,525 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,398 software developers and data experts.

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

Jul 23 '05 #1
3 1486
sa************@hotmail.com wrote:
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?


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

V
Jul 23 '05 #2
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:
sa************@hotmail.com wrote:
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?


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

V


Jul 23 '05 #3
sa************@hotmail.com wrote:
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) ?
Try std::vector<float> and std::vector<std::vector<float> >.
Then use pass by reference for passing them to functions.

[SNIP] if A is changed in both myfuncs will A1 and A2 change?


Depends on what you mean by change but generally yes.

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: fivelitermustang | last post by:
I have two matrices allocated dynamically in both directions: matrix x and matrix v. I want to pass these matrices into a function by reference. What I have written down isn't working... can...
5
by: lugal | last post by:
This might be more appropriate here. I'm new to C++, coming from a background in another languages that allowed a similar solution to work (Python). I wrote the following code in C++ based on the...
6
by: Adam Hartshorne | last post by:
Hi All, I have the following setup. Two 'std::vector's which i iterate through in a for (iterate through vector1 of types X) { for (iterate through vector2 of types Y) { f(x) }
13
by: Havatcha | last post by:
Does anyone know of a decent (free/easy to use) C++ library for manipulating matrices and caculating eigenvalues, eigenvectors and so on? I intend to add some Principal Component Analysis...
2
by: Morgan | last post by:
Thanks to all of you because I solved the problem related with my previous post. I simply made confusion with pointers to pointers and then succeeded passing the reference to the first element...
9
by: tomamil | last post by:
imagine that you have different matrices with different names and you want to perform the same action with each of them. is it possible to put their names into some array and to create a loop that...
2
by: danielhdez14142 | last post by:
Some time ago, I had a segment of code like vector<vector<int example; f(example); and inside f, I defined vector<int>'s and used push_back to get them inside example. I got a segmentation...
7
by: desktop | last post by:
I am not sure I quite understand the use of iterators. I have this int array: int a = {1,2,3,4,5} I would now like to make an iterator to the first and last element: std::iterator<intiter;...
3
by: runcyclexcski | last post by:
I have written an image processing app in Matlab which works fine when I analyse images one at a time, but is very slow when I have to analyze thousands of images in a row. So I re-wrote the image...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.