Exporting a 2D array.....

R

Relative0

I have a rather elusive problem and have spent some amount of time on
it, I would very kindly appreciate it if anyone could give me insight
on how to solve this problem. I tried to include what I thought was
necessary without overkilling it. Basically it seems as if a "lattice"
is being created. the tgrundgitter(~,~,~,~) is declared in another
header file. as well as heightfct(~,~). I don't understand what is
going on in the lattice->gethightfct(heightfct); and furthermore what
I really really want to do is get the 2Dimensional array "t2darray"
with all the elements in it and then transport them into the
d2_RootMeanSquare(int n, ?) function. I put ? in the function because
I don't know how to do this, I don't understand the syntax... Could
someone please help me out on how to do this and explain it to me???

Thanks,

Brian

lattice = new
tgrundgitter(latticeparameter.atomex,latticeparameter.atomey,latticeparameter.atomez,latticeparameter.gridtype);

t2darray<short>
heightfct(latticeparameter.atomex,latticeparameter.atomey);
lattice->gethightfct(heightfct);

TwoDimRMS.d2_RootMeanSquare(16,heightfct);


//---------- "In Header File".

public:
int d2_RootMeanSquare(int n, int vector[][16]);


int d2_RMS::d2_RootMeanSquare(int n, int vector[][16]){
for (a=0;a<n;a++){
x = 0;
for (b=0;b<n;b++){
x = x + pow(vector[a],2);
}}
 
A

Alf P. Steinbach

* Relative0:
I have a rather elusive problem and have spent some amount of time on
it, I would very kindly appreciate it if anyone could give me insight
on how to solve this problem. I tried to include what I thought was
necessary without overkilling it. Basically it seems as if a "lattice"
is being created. the tgrundgitter(~,~,~,~) is declared in another
header file. as well as heightfct(~,~). I don't understand what is
going on in the lattice->gethightfct(heightfct); and furthermore what
I really really want to do is get the 2Dimensional array "t2darray"
with all the elements in it and then transport them into the
d2_RootMeanSquare(int n, ?) function. I put ? in the function because
I don't know how to do this, I don't understand the syntax... Could
someone please help me out on how to do this and explain it to me???

Thanks,

Brian

lattice = new
tgrundgitter(latticeparameter.atomex,latticeparameter.atomey,latticeparameter.atomez,latticeparameter.gridtype);

t2darray<short>
heightfct(latticeparameter.atomex,latticeparameter.atomey);
lattice->gethightfct(heightfct);

TwoDimRMS.d2_RootMeanSquare(16,heightfct);


//---------- "In Header File".

public:
int d2_RootMeanSquare(int n, int vector[][16]);


int d2_RMS::d2_RootMeanSquare(int n, int vector[][16]){
for (a=0;a<n;a++){
x = 0;
for (b=0;b<n;b++){
x = x + pow(vector[a],2);
}}


The answer your problem is in the FAQ; see <url:
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.8>.
 
L

loufoque

Relative0 wrote :
int d2_RMS::d2_RootMeanSquare(int n, int vector[][16]){
for (a=0;a<n;a++){
x = 0;
for (b=0;b<n;b++){
x = x + pow(vector[a],2);
}}


To use operator[] with a multi-dimension array, all numbers of elements
for each dimension but the last must be known.
Therefore, to be able to do that you would need to declare vector
differently, for an example int[16][].
 
R

Relative0

Alf,

I am not sure what the link you sent me was for, but it seems
there are no answers, (atleast to the problem I am trying to figure
out).

Brian

* Relative0:
I have a rather elusive problem and have spent some amount of time on
it, I would very kindly appreciate it if anyone could give me insight
on how to solve this problem. I tried to include what I thought was
necessary without overkilling it. Basically it seems as if a "lattice"
is being created. the tgrundgitter(~,~,~,~) is declared in another
header file. as well as heightfct(~,~). I don't understand what is
going on in the lattice->gethightfct(heightfct); and furthermore what
I really really want to do is get the 2Dimensional array "t2darray"
with all the elements in it and then transport them into the
d2_RootMeanSquare(int n, ?) function. I put ? in the function because
I don't know how to do this, I don't understand the syntax... Could
someone please help me out on how to do this and explain it to me???

Thanks,

Brian

lattice = new
tgrundgitter(latticeparameter.atomex,latticeparameter.atomey,latticeparameter.atomez,latticeparameter.gridtype);

t2darray<short>
heightfct(latticeparameter.atomex,latticeparameter.atomey);
lattice->gethightfct(heightfct);

TwoDimRMS.d2_RootMeanSquare(16,heightfct);


//---------- "In Header File".

public:
int d2_RootMeanSquare(int n, int vector[][16]);


int d2_RMS::d2_RootMeanSquare(int n, int vector[][16]){
for (a=0;a<n;a++){
x = 0;
for (b=0;b<n;b++){
x = x + pow(vector[a],2);
}}


The answer your problem is in the FAQ; see <url:
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.8>.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
R

Relative0

loufoque,

I am not sure what you mean, so I am supposed to put int
vector[16][], what does this do and what do I do with it? I am a bit
new, (relatively speaking), so perhaps you might go a little more in
depth?

Thanks,

Brian

Relative0 wrote :
int d2_RMS::d2_RootMeanSquare(int n, int vector[][16]){
for (a=0;a<n;a++){
x = 0;
for (b=0;b<n;b++){
x = x + pow(vector[a],2);
}}


To use operator[] with a multi-dimension array, all numbers of elements
for each dimension but the last must be known.
Therefore, to be able to do that you would need to declare vector
differently, for an example int[16][].
 
L

loufoque

Relative0 wrote :
loufoque,

I am not sure what you mean, so I am supposed to put int
vector[16][], what does this do and what do I do with it? I am a bit
new, (relatively speaking), so perhaps you might go a little more in
depth?

If you have "int vector[][16]" then you can't do vector[a](b] because
the size of the first dimension is not known.
 
R

Ron Natalie

loufoque said:
Relative0 wrote :
loufoque,

I am not sure what you mean, so I am supposed to put int
vector[16][], what does this do and what do I do with it? I am a bit
new, (relatively speaking), so perhaps you might go a little more in
depth?

If you have "int vector[][16]" then you can't do vector[a](b] because
the size of the first dimension is not known.
You most certainly can. Vector[][16] is array of unknown size
of arrays of 16 ints. That's all you need to know to do
vector[a]. The only thing you don't know is the sizeof
the entire object.
 
L

loufoque

Ron Natalie wrote :
You most certainly can. Vector[][16] is array of unknown size
of arrays of 16 ints.
That's all you need to know to do
vector[a]. The only thing you don't know is the sizeof
the entire object.


Seems like I got the order wrong then.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,792
Messages
2,569,639
Members
45,353
Latest member
RogerDoger

Latest Threads

Top