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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 problem when working with vector & matrix
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Simon.N

France
Posts

Posted - 07/03/2007 :  06:27:54 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

Simon.N

France
Posts

Posted - 07/03/2007 :  10:17:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000