CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

how to add vector matrix

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Laus



Joined: 16 Jan 2016
Posts: 17
Location: Brazil

View user's profile Send private message

how to add vector matrix
PostPosted: Sun Jul 28, 2019 10:56 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Jul 28, 2019 11:59 am     Reply with quote

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];
   }
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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