The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 problem when working with vector & matrix

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Simon.N Posted - 07/03/2007 : 06:27:54 AM
Origin Version (Select Help-->About Origin): 7 SR2
Operating System: vista

Hi,

This is the context :

I have two matrix of integers (mipower & midate).
I want to copy each row of them in different worksheet (ie having in each of the new worksheet, the nth row of mipower and the nth row of midate).

Unfortunately, the numbers i have at the end are not the one expected.

here is my code :

for(jj=0; jj<iNbNommines; jj++)
{
//int iIndexCol = wks.AddCol(/*"candidat"*/);
Worksheet feuille_resultats;
feuille_resultats.Create();
Column colDate = feuille_resultats.Columns(0);
Column colPower = feuille_resultats.Columns(1);
Dataset dsdate;
dsdate.Attach(feuille_resultats, 0);
Dataset dspower;
dspower.Attach(feuille_resultats, 1);
dsdate.SetSize(viNbEvent[jj]);
dspower.SetSize(viNbEvent[jj]);


for(int kk=0; kk<viNbEvent[jj]; kk++)
{
dspower[kk]=miNommineP[jj][kk];
dsdate[kk]= dsTime[miNommineD[jj][kk]]; //here is a first problem since dsdate expects an integer whereas dsTime contains a date type (ex 03-07-2007 12:22:45).
printf("right value: %d, left value : %d\n", miNommineP[jj][kk], dspower[kk]);
}
}



The resulting worksheet contains only '0' for the column dspower, and '-' for the column dsdate.

Besides, here is the trace of the printf line :

right value : 0, left value : 0
right value : 0, left value : 0
right value : 0, left value : 0
right value : -97, left value : 0
right value : 0, left value : 0
right value : 0, left value : 0


Hope you'll can help me.

Thanks.

Simon Nicolas
1   L A T E S T    R E P L I E S    (Newest First)
Simon.N Posted - 07/03/2007 : 10:17:18 AM
I have modified the inner loop like this :


for(int kk=0; kk<viNbEvent[jj]; kk++)
{
int tmp=miNommineP[jj][kk];
dspower[kk]=tmp;
dsdate[kk]= dsTime[miNommineD[jj][kk]]; //here is a first problem since dsdate expects an integer whereas dsTime contains a date type (ex 03-07-2007 12:22:45).
printf("right value: %d, left value : %d, tmp value\n", miNommineP[jj][kk], dspower[kk], tmp);
}




And now, the results are the same, but the printf command displays -1067958272 if right value is negative or 1079181312 if right value is positive.

It seems to be the limits of an integer type.

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000