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 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
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 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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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)
}
|
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...
|
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...
|
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...
|
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...
|
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;...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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...
|
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: 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...
|
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...
| |