[Scilab-users] ODE is returning a vector of wrong size

2014-12-29 Thread Ezequiel Soule

Hello, when ODE is called to solve a differential equation:

x=ode(y0, t0, t, f)

"t" is the vector containing the times at which the solution is computed.

In some cases, it returns a vector x which has less elements than t!

When this happens I get a warning message:

lsoda--  at t (=r1) and step h (=r2), the
   corrector does not converge
  with abs(h) = hmin
  where r1 is :   0.4573527645205D+02   and r2 : 0.1425423380287D-03
Advertencia: Los resultados pueden ser inexactos.

Why is this happening and how can it be corrected?
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Problems using save

2014-10-21 Thread Ezequiel Soule
Hello, unfortunately I cannot give you a solution, instead I´ll give you 
another problem!
I had the problems you mention also, and in addition, another one. When 
I try to load a file, I get an error:


!--error 41
Argumento de salida incompatible.
at line  16 of function coord called by :
at line  14 of function createMacro called by :
at line   8 of function %__convertVariable__ called by :
at line 978 of function %_sodload called by :
load("xxx.sav")

This seems to happen when I define functions with arrays as input 
variables. The functions work fine, but give this error when saved and 
loaded. I can load specific variables, but not the whole file.


El 21/10/2014 01:24 p.m., Matiasb escribió:

Hi,

After executing a script that creates a lot of variables and big matrices,
I'm trying to make a backup of what it created. A good option would be to
save all variables to a file, as the  save
   function allows when
a list of variables is not specified.
Something like: save('backup.dat')

But when I use this function I found 2 problems:
 1) Very strangely, it opens a graph window with some plots. Screenshot:
Selection_420.png

 2) when there are a lot of variables it takes veeery long, the scilab
process uses 2GB of mem. If there are big matrices the scilab process hangs
completely.

*For 1)* I tried to track it and I could reproduce with a simple example:
the problem occurs when I define a function that uses some graph function.
For example, creating a test.sce file with the following function:
// test.sce
function []=MyTest()
 xtitle("Testing save");
endfunction

Then in the console:
   clear; // just to start from scratch
   exec('test.sce', -1);
   save('backup.dat'); // this opens the graph window!

*For 2)*, I'm using stacksize('max') to increase scilab's memory to the
maximum. I checked that saving variables individually (passing their names
to the save function) works fast as expected and scilab does not hang even
when saving big matrices. The problem is that i can not use that solution as
the process creates each time different variables so it is not practical to
name each variable one by one.

Maybe the problem in 2) is related with 1) but its hard for me to run the
process and not define those functions.

Is there a way for me to store all this created variables in a file without
these problems?
Maybe solving 1) will fix it. Maybe there is a way to put all the variables
in an array so that save can take that as a parameter.

Any help would be appreciated!
Thank you very much

Matias

PD: I'm using scilab 5.4.1 in Linux.









--
View this message in context: 
http://mailinglists.scilab.org/Problems-using-save-tp4031410.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at 
Nabble.com.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Pairwise distance of a huge amount of points

2014-09-01 Thread Ezequiel Soule
Hi, I am working in something related, which is deteriming overlaps in a 
sistem of spheres with random positions. So I have to compute the 
distance between centers of spheres, and compare it with the contact 
distance. I implemented a cell algorithm, which is used in molecular 
dynamics (you can look it up in internet if you don´t know it): 
essentially you divide the space in "cells", with a size that has to be 
larger than the maximum posible distance, then you identify in which 
cell each point is located, and then you compute the distance between 
each point and the points located in the same and the neigbhouring 
cells. The speed of the algorithm scales with n, and the computed 
distance matrix has n*c*b non-zero elements, where "c" is the average 
number of points in a cell and "b" is the number of neiborghs of each 
cells, plus one. "c*b" might be orders of magnitude smaller than "n" so 
there is a big advantaje in using sparse matrices. I used this with 
hundred thousands spheres without exeding the maximum stacksize.
The only problem is that you need to know the maximum possible distance 
in order to define the cell size (if your cell is to small you can miss 
relevant meassurements, if it is too large, you lose efficiency); I 
don´t know if this is possible in your application.


El 29/08/2014 07:01 p.m., Samuel Gougeon escribió:

Le 29/08/2014 12:58, Dang, Christophe a écrit :

Just to close the subject:

I tried to implement the algorithm with sparse matrices, and it is 
less efficient than scanning over one dimension: 7 times faster than 
the naive algorithm.
Yes, it was somewhat expected. Also for memory consumption, the sparse 
encoding becomes interesting vs the dense encoding only when the 
sparsity becomes smaller than .. 50%.
There was a quite recent thread on bugzilla, about the relevance of 
keeping a sparse encoding for the result of cos(SP) where SP is a 
sparse (so with a good fraction of null values).
It was finally -- wisely -- decided (after some tests) to switch to a 
dense encoding for that case (as it should be for any function turning 
0 into a non-null value).


Samuel

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] problem with splin3D

2013-09-05 Thread Ezequiel Soule
Hello: I have a problem using the function splin3D(x,y,z,V) (for spline 
interpolation in 3D):


whenever the vectors x,y,z have a diferent size, I get an error message: 
problem with flag "n", where n is the number of elements of one of the 
vectors (not always the same). The dimensions are correct, this is V is 
an nx x ny x nz hypermatrix as should be, when this is not the case the 
error message is different.


thank you,

Ezequiel


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] problem loading environments

2013-08-05 Thread Ezequiel Soule

clear

function  f=fiso(var,intP,param)

fiazo=var(1);
xt=var(2);
T=var(3);
I=var(4);

nu=intP;
chi=1;

rp=1;
razo=param;
  
  f  =  fiazo*xt/razo*log(fiazo*xt)  +  fiazo*(1-xt)/razo*log(fiazo*(1-xt))  +  (1-fiazo)/rp*log(1-fiazo)+  chi*fiazo*(1-fiazo);  


endfunction

function  f=ftot(xt,p,intP,param)
var=[p(1)  xt  p(2)  p(3)];
f  =  fiso(var,intP,param);

endfunction

save("ejem.sav")
 
load("ejem.sav")


The error message is:
Incompatible output argument
at line   3 of function ftot called by :
at line  14 of function createMacro called by :
at line   8 of function %__convertVariable__ called by :
at line 855 of function %_sodload called by :
load("ejem.sav")

But, doing the same without the variables intP, param, this is, 
defining  the function fiso as fiso(var), and given some value to intP 
and param within the function... works fine!

Any help will be appreciated.


El 03/08/2013 08:34 a.m., Mathieu Dubois escribió:
Could you send a simple example which creates a simple environement 
that shows the problem when saved and restored?


Mathieu

Le 31/07/2013 14:51, Ezequiel Soule a écrit :

Hello, I keep having this problem, when I try to load a saved
ennironments, I get an error "incompatible output arguments" in some
function of the environment, and it doesn´t load anything. The function
that gives the error works fine, and I don´t get any error when I
execute or call the function, just when loading the environment. It is
not one particular function, it happened many times, with different
environements and different functions. I can load some of the variables
if I specifiy then, but I can´t load the whole thing.
This happens wiht versions 5.4.0 and 5.4.1, I haven´t try older 
versions.


Any ideas?
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] problem loading enviroment

2013-03-21 Thread Ezequiel Soule
Hello, sometimes, when I try to load an eviroment, I got a message like 
this:


loading initial environment
 Warning : redefining function: %_sodload   . Use 
funcprot(0) to avoid this message

   inside function: createMacro .

= (pos,V,R,calc_D_superp_dobcel(N, N2))
!--error 41
Incompatible output argument.
at line  16 of function coord called by :
at line  13 of function createMacro called by :
at line   8 of function %__convertVariable__ called by :
at line 836 of function %_sodload called by :
 then load(%fileToLoad); disp(msprintf(gettext
while executing a callback


and it does´t load anything. I had no problem saving it, or runing it, 
or manipulating the variables, or any kind of problem before or after 
saving, but it does not load...


there seems to be some problem with some of the functions saved in the 
enviroment but, I repeat, I had no problem saving or running them. I can 
load the variables if I list them (as in 
load("filename","var_1","var_2",..."var_n")), but it is really stupid I 
have to do this instead of just loading everything...

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] voronoi in 3D space

2013-01-31 Thread Ezequiel Soule
Hello, does anyone one if there is any tool to calculate voronoi 
diagrams in a 3D space? I coulnd't find anything for scilab, but it 
exists in matlab, so maybe I just missed it...

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] modifying a variable changes the value of another variable!!!

2013-01-29 Thread Ezequiel Soule

Hi Rafael, thank you for your answer.
I'm running the code with the minimum variables required for it 
(positions, radius, number of spheres).
it can be some sort of error generating in the output (or in some 
internal calculation) of calc_D_superp_dobcel, but I don't think it is 
roundoff, why would that change when defining a different variable or 
adding a command with no connection? superp0 and superp1, as you told me 
to define them, are the same (superp0-superp1=0), so the error is not 
produced in those lines, it is something less direct. I'm not expert, 
but I guess what is happenning here is that, using a section of the RAM, 
the stack, the space where variables are stored, or whatever it is, is 
sligthly modifying OTHER sections of the RAM or wathever. Some bug of 
scilab, or maybe it is a common thing in every program but usually goes 
unnoticed (which would be understandable, it is a 1e-15 error, most of 
the times it will be not significant).
Right after writting this, and remembering some issues like the division 
by zero... I had an idea (is "epiphany" too pretencious?), and I ran it 
on ubuntu... the problem is gone! There is no error under ubuntu. So the 
problem is in Windows (it is Windows server, I can check Windows Vista 
in a few days...). the question is: Is it a Windows bug, or a 
Scilab-for-Windows bug?
By the way, the obvious solution for me would not work. I cannot run my 
simulations in my ubuntu machine, we have the workstation for large 
calculations so we don't overload our personal computers, and the 
worstations runs with Windows server... Well, I can test my control 
system in my ubuntu machine, but not run the real thing...




On 28/01/13 21:50, Rafael Guerra wrote:

 From the code excerpt provided it is difficult to see from where errors of
magnitude~=1e-15 might come from.

Could they be due to some round-off errors in the function:
calc_D_superp_dobcel? Please check the function details.

Have you run the code with a "clear" at the beginning of the program to
clean all variables?

// Could you please define before your 3rd control system:
superp0= superp;
// and after your 3rd control system:
superp1= superp;
printf("%i...delta(superp) = %e", control, max(abs(superp1-superp0)) )
// and tell us what values do you get? Do the errors of 1e-15 magnitude
occur and at which "control" iterations?


// Non related to your problem, herebelow are some suggestions, if you will,
to make your code more easy to read:

//define additional variables to simplify the code:
m = int(control/max_mov*20);
N = length(sup_2);
s = sum(superp);

// write:
while max(superp)>tol & control<=max_mov // moving "control=control+1" to
the end of the while loop


PS: "sumsupant"  // this variable is not defined in the code excerpt, looks
like =sum(superp)


Regards,
Rafael G.



--
View this message in context: 
http://mailinglists.scilab.org/modifying-a-variable-changes-the-value-of-another-variable-tp4025762p4025819.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at 
Nabble.com.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] modifying a variable changes the value of another variable!!!

2013-01-28 Thread Ezequiel Soule
Sorry I didn't clarify that: I define the initial random positions, I 
store them in a variable, say pos_in, and then I call the functions (the 
different versions) with pos_in as input, so the initial positions are 
the same in every case.


On 28/01/13 14:07, Serge Steer wrote:
If the initial position of your sphere are randomly set, it can be 
normal than you do not have the same number of iteration from one 
simulation to an other one.

can you check using
rand("seed",0)
to force identical initial points for your various tests.

Serge Steer
Le 28/01/2013 16:18, Ezequiel Soulé a écrit :
The algorithm essentially starts with a set of spheres in random 
positions and in a relatively dense state, and runs an iterative 
process where the spheres are moved in each iteration in order to 
reduce the overlaps.

The core of the script is more or less like this

superp=calc_D_superp_dobcel(pos);   //this line uses an external function 
to calculate a matrix with the overlap between paritcles, defined as 
superp(i,j)=max(R(i)+R(j)-D(i,j),0) . D(i,j) is the distance between the 
spheres and R is the radius. pos is a 3-colum matrix containging the 
coordinates of the position of each sphere

 control=0; //number of iterations


sup_2(int(control/max_mov*20)+1)=sumsupant/max_mov*20;   // this defines a 
third control system as will be described bellow. **

while  max(superp)>tol   // the maximum value of superp controls when the 
system is considered overlap-free and the algorithm is finished


...
// Several lines where the positions of each sphere are modified, acording to 
the values of the matrix superp
...
 
superp=calc_D_superp_dobcel(pos);   //matrix superp is re-calculated with the new positions



control=control+1;

  if  control>max_mov  then  break;  end// control by maximum number of 
iterations
  
//the following belongs to the third control system:
 
 if  length(sup_2)==int(control/max_mov*20)  then  sup_2(int(control/max_mov*20)+1)=sum(superp)/max_mov*20; //**

 else//**
sup_2(int(control/max_mov*20)+1)=sup_2(int(control/max_mov*20)+1)  +  
sum(superp)/max_mov*20;//**
end  //**
  
   if  length(sup_2)>4.5  then //**

   if  sup_2($-1)>0.85*sup_2($-2)  &  sup_2($-2)>0.85*sup_2($-3)  then  
break;  end  //**
   if  sup_2($-1)>0.7*sup_2($-2)  &  sup_2($-2)>0.7<
  span styl
e="color:rgb(92,92,92)">*sup_2($-3)  &  sup_2($-3)>0.6*sup_2($-4)  then  break; 
 end //**
   end  //**

end//ends while loop

The third control system essentially controls if the overlap is 
decreasing as the iterations proceed. It defines a new variable, 
sup_2, that stores the average value of sum(superp) in max_mov/20 
iterations. If this average does not decrease fast enough (>15% 
decrease in two or >30%decrease in three consecutive groups of 
max_mov/20 iterations), it considers that it will not converge and 
breaks.
Now, this third control system seems to be problem. As you can see, 
non of its lines (marked with ** for more clarity), affects the 
values of superp (at least, it shouldn´t). But still, the value of 
superp is modified when I include this control system.
The other problem I had was with a similar algorithm, without the 
third control system, but just adding a "pause" rigth after the last 
end. This will also modify the values of superp and the number of 
iterations.
As I said, the error in superp is not important (it is in the order 
of 1.d-15), but this difference propagates exponentially through the 
iterations and can significantly modify (like a 30%) the total number 
of iterations (I was trying to evaluate if the third control really 
worked, but I couldn´t do it because the algortihm CONVERGES with a 
different number of iterations...)



___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users




___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] modifying a variable changes the value of another variable!!!

2013-01-28 Thread Ezequiel Soule

Hello, I am using some iterative algorithm defined as a function in a .sci 
file, and I have the following problem: the iterations in the algorithm are 
controlled by a given variable. Now, if I define another variable, (which DO 
NOT affect the values of the control variable nor the way it is calculated) in 
the function, the number of iterations to converge changes! What happens is 
that the value of the control variable, for some reason, is modified. It is not 
a very significant modification, actually the difference is in the order of 
10^-15... the problem is that this difference propagates exponentially as the 
iterations advance, and the total number of iterations and the final result 
(which is not unique) can be modified drastically!
My question is, why the value of the control variable is modifyied by the definition a 
completely independent variable. I saw this problem in scilab 5.4.0 and 5.2.2. I also had 
a similar, but worse, problem, before with a similar algorithm. I just added a command 
"pause" in the function, and this command was even OUTSIDE the while loop that 
defined the iterations... and the number of iterations was modyfied. How can this happen?

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] modifying a variable changes the value of another variable!!!

2013-01-25 Thread ezequiel soule
Hello, I am using some iterative algorithm defined as a function in a .sci
file, and I have the following problem: 
the iterations in the algorithm are controlled by a given variable. Now, if
I define another variable, (which DO NOT affect the values of the control
variable nor the way it is calculated) in the function, the number of
iterations to converge changes! What happens is that the value of the
control variable, for some reason, is modified. It is not a very significant
modification, actually the difference is in the order of 10^-15... the
problem is that this difference propagates exponentially as the iterations
advance, and the total number of iterations and the final result (which is
not unique) can be modified drastically!
My question is, why the value of the control variable is modifyied by the
definition a completely independent variable.
I saw this problem in scilab 5.4.0 and 5.2.2.
I also saw a similar, but worse, problem, before with a similar algorithm. I
just added a command "pause" in the function, and this command was even
OUTSIDE the while loop that defined the iterations... and the number of
iterations was modyfied. How can this happen?



--
View this message in context: 
http://mailinglists.scilab.org/modifying-a-variable-changes-the-value-of-another-variable-tp4025762.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at 
Nabble.com.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users