|
|
View previous topic :: View next topic |
Author |
Message |
Laus
Joined: 16 Jan 2016 Posts: 17 Location: Brazil
|
how to add vector matrix |
Posted: Sun Jul 28, 2019 10:56 am |
|
|
long xcc[]={0,0,1,1};
long ycc[]={1,1,1,1};
int out[];
out[]=ycc[]+xcc[];
out[]=={1,1,1,1,0,0,1,1}; // I need this output, how to get this? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19495
|
|
Posted: Sun Jul 28, 2019 11:59 am |
|
|
First thing is you need to give 'out' a size. Your initialised arrays are given
sizes, because you initialise them, However the uninitialised array won't
be given storage.
Then what you show is not standard matrix addition. The addition of
xcc, and ycc would give {1,1,2,2}.
There is also an issue, in that your source values are declared as 'long',
so could be up to 65535, but your destination array is only declared as
'int', so could only hold values up to 255.
You seem to be wanting just the stored vals concatenated into the target.
Concatenation:
Code: |
long out[8];
int cnt;
for (cnt=0;cnt<4;cnt++)
{
out[cnt]=ycd[cnt];
out[cnt+4]=xcd[cnt];
}
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|