Register to reply 
Why isn't this a machine sized integer 
Share this thread: 
#1
Feb2712, 10:03 AM

P: 894

In:list5 = Import["Composites.csv"]; (*imports a list of odd integers each less than 1000000*)
Timing[f=Compile[{{Caa,_Integer},{S0,_Integer},{S1,_Integer},{Co,_Integer}}, Module[{xCo=Co,xS0=S0,xS1=S1,Temp},While[Temp=Mod[6 xS1xS06,Caa];xCo>0&&Temp>=1, xS0=xS1;xS1=Temp;xCo]; xCo]]; count = Length[list5]; list3=Reap[While[count>0, Caa= list5[[count]];Sow[Caa];Co=Round[(Caa2)/2];S0=2;S1=3; So = f[Caa,S0,S1,Co]; Sow[So]; count]]] results in red msg: {3827} in position 1 should be a machine size Integer, {13067} in position 1 should be a machine size Integer, etc These are integers from the imported list. I am at loss as how to correct this error. Please help. PS when I switched the positions of Caa and Co in the compiled function, I get in red {1913} in position 1 should be a machine sized integer, etc. 


#2
Feb2712, 10:27 AM

P: 3,096

Is this for a course?
What language is this, what machine and what OS? machine sized ints vary with cpu and language usage. For C/C++ a machine sized int +32768 or 16bit integer For Java an int is a 32bit value. Also check your csv file to see if any numbers are greater than the 1000000 mentioned in the comment. Thats if this program had worked before but now does not. 


#3
Feb2712, 10:34 AM

Mentor
P: 21,397




#4
Feb2712, 12:33 PM

P: 894

Why isn't this a machine sized integer
Opps. Sorry but this is code for Mathematica. I should have made that clear in the title
PS I understand that integers less than 2^31 may qualify as machine readable. I think the {} may be making the number not be an "integer" but if that is the problem, how do I get rid of them, i.e. let the element be the number per se and not {3427}. 


#5
Feb2712, 12:39 PM

P: 3,096

noticed an extra space in your code is that an artifact of display on this forum or is it really there.
,{S1,_Integer},{Co,_I nteger}}, __________________^_________ maybe this space is causing the trouble 


#6
Feb2712, 01:03 PM

P: 894




#7
Feb2712, 01:24 PM

P: 1,043

Remember that long list of warnings and cautions I gave you about Compile[] and one of those was that all integers needed to be less than 32 bits. It looks like you either have a small syntax problem or you have stepped over that limit.
By trial and error see if you can create a MUCH shorter list Composites.csv that still demonstrates this error, post that here and I'll see if I can figure out what you have done. I don't want to have to dig through thousands of numbers to discover where your problem is. But as I also said, when you ran into troubles with a Compile I might easily not be the person to figure it out for you. And yes, that annoying space and other formatting problems show up in text pasted onto the forum. I mentioned that before. That isn't the problem, just as long as you remember to watch for and fix that. I think that inserting a few spaces after commas or operators sometimes makes the problem hide. 


#8
Feb2712, 01:53 PM

P: 894




#9
Feb2712, 07:02 PM

P: 1,043

CompiledFunction:: cfsa: Argument {75} at position 1 should be a machinesize integer. and got that for each integer. That looks EXACTLY like the error message you are reporting. I then inserted Print[FullForm[list5]]; immediately after your list5=Import[...] and discovered that a column of integers comes in as a list of lists when you are expecting list5 to be just a list so I am guessing that your input from Excel is not in the form that you are trusting it to be. Try inserting list5 = Flatten[list5]; after your list5=Import[...] and see if you get a better result. 


Register to reply 
Related Discussions  
To understand how spherical harmonics apply to integer spin but not half integer spin  Quantum Physics  10  
Angular momentum  integer or halfinteger  Quantum Physics  2  
Proof Question: Prove integer + 1/2 is not an integer  Calculus & Beyond Homework  4  
Material in machine tool body (milling machine)  Materials & Chemical Engineering  0 