Re: [Scilab-users] number od decimals with csvWrite

2015-06-26 Thread Serge Steer

The simplest way is to use round

A=rand(3,3);
B=round(100*A)/100;

Serge Steer
Le 25/06/2015 22:07, Simone Meroni a écrit :

Hi
I want to write some data and export them with

csvWrite

I need to have no more than 2 decimals for aesthetic reasons.

How can I set the number of decimals?

Thanks,

Simone Meroni


___
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] eigs calculation

2015-06-26 Thread Antoine Monmayrant
Hi Paul,

I don't really like a function that gives different answers for the very same 
input.
That sounds like a bug to me.
That being said, from the data you showed, it is not clear that your 
eigenvector are really different.
If what you show is just a difference in the norm of the difference between the 
eigenvalue at iteration 1 and N, that might be OK.
Indeed, if v is an eigenvector, a.v with a non zero-scalar, is also an 
eigenvector.
You should check whether v1 and vN are colinear: if they are, the results are 
not really different, they just differ by a scaling factor.
But I would still call it a bug, as a function should always give the same 
answer when given the same input parameters.

Cheers,

Antoine

 
Le Jeudi 25 Juin 2015 17:17 CEST, "Carrico, Paul"  
a écrit: 
 
> Dear all
> 
> I'm still working on my "eigs" issue topic and I'm still trying to understand 
> what's going wrong;
> 
> I run a test case :
> - same function is launched 10 times
> - each time the input data are recorded (K,M)
> - for each loop the eigenvalues u and the eigenvectors v are recorded
> 
> Then the values of each loop are compared with the values of the loop 1
> 
> If K,M,u remains strictly identical, it is not the case for u (the 
> eigenvectors) ... why ?
> 
> I've ever check any initialization issue, but everything seems to be ok
> 
> Paul
> 
> PS : the results of this case
> 
> Max delta v2 - v1 = 453.857
> Max delta K2 - K1 = 0
> Max delta M2 - M1 = 0
> 
> Max delta v3 - v1 = 549.214
> Max delta K3 - K1 = 0
> Max delta M3 - M1 = 0
> 
> Max delta v4 - v1 = 585.95
> Max delta K4 - K1 = 0
> Max delta M4 - M1 = 0
> 
> Max delta v5 - v1 = 379.702
> Max delta K5 - K1 = 0
> Max delta M5 - M1 = 0
> 
> Max delta v6 - v1 = 489.844
> Max delta K6 - K1 = 0
> Max delta M6 - M1 = 0
> 
> Max delta v7 - v1 = 439.221
> Max delta K7 - K1 = 0
> Max delta M7 - M1 = 0
> 
> Max delta v8 - v1 = 432.406
> Max delta K8 - K1 = 0
> Max delta M8 - M1 = 0
> 
> Max delta v9 - v1 = 351.752
> Max delta K9 - K1 = 0
> Max delta M9 - M1 = 0
> 
> Max delta v10 - v1 = 554.515
> Max delta K10 - K1 = 0
> Max delta M10 - M1 = 0
> 
> -Message d'origine-
> De : Carrico, Paul
> Envoyé : mercredi 17 juin 2015 22:18
> À : International users mailing list for Scilab.
> Objet : RE: [Scilab-users] eigs calculation
> 
> Dear All
> 
> Thanks for the answers.
> 
> To give more information's on what I'm doing (That's quite new I confess), 
> I'm performing  a (basic) finite element calculation with beams using sparse 
> matrix (stiffness matrix K and mass matrix M).
> [u,v] = 
> eigs(K((ddl_elem+1):$,(ddl_elem+1):$),M((ddl_elem+1):$,(ddl_elem+1):$),n,"SM");
> 
> Nota: ddl means dof
> 
> I'm calculated first the natural frequencies using (K - omega^2.M).x=0 ... 
> the pulse (or circular frequencies)  are no more and no less than the 
> eigenvalues of the above system (u = omega^2).
> 
> Just a "mechanical" remark: since the beam is clamped in one side (and free 
> on the tip),  it is absolutely normal that you find twice the same natural 
> frequency (1rst mode in one direction, the second one in a new direction at 
> 90°)  I've been really surprised to find it, but happy at the same time 
> ...
> 
> The origin of my question was: since it obvious that the results are strongly 
> sensitive to the "units" (i.e. the numbers), I'm wondering if there is a way 
> to control the accuracy of the eigenvalues calculation using eigs keywords 
> ... 
> 
> In any way, thanks for the debate
> 
> Paul
> 
> EXPORT CONTROL : 
> Cet email ne contient pas de données techniques
> This email does not contain technical data
> ___
> 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] eigs calculation

2015-06-26 Thread Carrico, Paul
Hi Antoine,

Thanks for the comments; In attachment the results of the calculations (note 
that the modal effective depends on the eigenvectors)

The calculation for the difference calculations are described herebellow ..


Paul

###"
// prog principal
nbre = 10;
for k = 1 : nbre
printf("\n***\nIteration num %d\n",k);
s1 = "  ...
[u" + string(k) + ",v" + string(k) + ",K" + string(k) + ",M" + string(k) + 
"] = calcul_v() , ...
[nl,nc] = size(v" + string(k) + ") , ...
save(''u" + string(k) + ".bin'',''u" + string(k) + "'') , ...
save(''v" + string(k) + ".bin'',''v" + string(k) + "'') , ...
clear nl , ...
clear nc , ...
save(''K" + string(k) + ".bin'',''K" + string(k) + "'') , ...
save(''M" + string(k) + ".bin'',''M" + string(k) + "'') , ...
";
execstr(s1) ;
  
end

printf("\n\n");

// difference v1 - v2
for k = 2 : nbre
s2 = " ...
printf(""(eigenvalues) Max delta u%d - u1 = %g\n"",k,abs(max(u" + string(k) 
+ " - u1))) , ...
printf(""(eigenvectors) Max delta v%d - v1 = %g\n"",k,abs(max(v" + 
string(k) + " - v1))) , ...
printf(""(input matrix) Max delta K%d - K1 = %g\n"",k,abs(max(K" + 
string(k) + " - K1))) , ...
printf(""(input matrix) Max delta M%d - M1 = %g\n"",k,abs(max(M" + 
string(k) + " - M1))) , ...
";
execstr(s2) ;
printf("\n");
end
##"


















-Message d'origine-
De : users [mailto:users-boun...@lists.scilab.org] De la part de Antoine 
Monmayrant Envoyé : vendredi 26 juin 2015 10:50 À : International users mailing 
list for Scilab.
Objet : Re: [Scilab-users] eigs calculation

Hi Paul,

I don't really like a function that gives different answers for the very same 
input.
That sounds like a bug to me.
That being said, from the data you showed, it is not clear that your 
eigenvector are really different.
If what you show is just a difference in the norm of the difference between the 
eigenvalue at iteration 1 and N, that might be OK.
Indeed, if v is an eigenvector, a.v with a non zero-scalar, is also an 
eigenvector.
You should check whether v1 and vN are colinear: if they are, the results are 
not really different, they just differ by a scaling factor.
But I would still call it a bug, as a function should always give the same 
answer when given the same input parameters.

Cheers,

Antoine

 
Le Jeudi 25 Juin 2015 17:17 CEST, "Carrico, Paul"  
a écrit: 
 
> Dear all
> 
> I'm still working on my "eigs" issue topic and I'm still trying to 
> understand what's going wrong;
> 
> I run a test case :
> - same function is launched 10 times
> - each time the input data are recorded (K,M)
> - for each loop the eigenvalues u and the eigenvectors v are recorded
> 
> Then the values of each loop are compared with the values of the loop
> 1
> 
> If K,M,u remains strictly identical, it is not the case for u (the 
> eigenvectors) ... why ?
> 
> I've ever check any initialization issue, but everything seems to be 
> ok
> 
> Paul
> 
> PS : the results of this case
> 
> Max delta v2 - v1 = 453.857
> Max delta K2 - K1 = 0
> Max delta M2 - M1 = 0
> 
> Max delta v3 - v1 = 549.214
> Max delta K3 - K1 = 0
> Max delta M3 - M1 = 0
> 
> Max delta v4 - v1 = 585.95
> Max delta K4 - K1 = 0
> Max delta M4 - M1 = 0
> 
> Max delta v5 - v1 = 379.702
> Max delta K5 - K1 = 0
> Max delta M5 - M1 = 0
> 
> Max delta v6 - v1 = 489.844
> Max delta K6 - K1 = 0
> Max delta M6 - M1 = 0
> 
> Max delta v7 - v1 = 439.221
> Max delta K7 - K1 = 0
> Max delta M7 - M1 = 0
> 
> Max delta v8 - v1 = 432.406
> Max delta K8 - K1 = 0
> Max delta M8 - M1 = 0
> 
> Max delta v9 - v1 = 351.752
> Max delta K9 - K1 = 0
> Max delta M9 - M1 = 0
> 
> Max delta v10 - v1 = 554.515
> Max delta K10 - K1 = 0
> Max delta M10 - M1 = 0
> 
> -Message d'origine-
> De : Carrico, Paul
> Envoyé : mercredi 17 juin 2015 22:18
> À : International users mailing list for Scilab.
> Objet : RE: [Scilab-users] eigs calculation
> 
> Dear All
> 
> Thanks for the answers.
> 
> To give more information's on what I'm doing (That's quite new I confess), 
> I'm performing  a (basic) finite element calculation with beams using sparse 
> matrix (stiffness matrix K and mass matrix M).
> [u,v] =
> eigs(K((ddl_elem+1):$,(ddl_elem+1):$),M((ddl_elem+1):$,(ddl_elem+1):$)
> ,n,"SM");
> 
> Nota: ddl means dof
> 
> I'm calculated first the natural frequencies using (K - omega^2.M).x=0 ... 
> the pulse (or circular frequencies)  are no more and no less than the 
> eigenvalues of the above system (u = omega^2).
> 
> Just a "mechanical" remark: since the beam is clamped in one side (and free 
> on the tip),  it is absolutely normal that you find twice the same natural 
> frequency (1rst mode in one direction, the second one in a new direction at 
> 90°)  I've been really surprised to find it, but happy at the same time 
> ...
> 
> The

Re: [Scilab-users] eigs calculation

2015-06-26 Thread Antoine Monmayrant
 
Le Vendredi 26 Juin 2015 11:16 CEST, "Carrico, Paul" 
 a écrit: 
 
> Hi Antoine,
> 
> Thanks for the comments; In attachment the results of the calculations (note 
> that the modal effective depends on the eigenvectors)
> 
> The calculation for the difference calculations are described herebellow ..

I'm confused, who's who:
u = value or vector
v = value or vector ?

Antoine

> 
> 
> Paul
> 
> ###"
> // prog principal
> nbre = 10;
> for k = 1 : nbre
> printf("\n***\nIteration num %d\n",k);
> s1 = "  ...
> [u" + string(k) + ",v" + string(k) + ",K" + string(k) + ",M" + string(k) 
> + "] = calcul_v() , ...
> [nl,nc] = size(v" + string(k) + ") , ...
> save(''u" + string(k) + ".bin'',''u" + string(k) + "'') , ...
> save(''v" + string(k) + ".bin'',''v" + string(k) + "'') , ...
> clear nl , ...
> clear nc , ...
> save(''K" + string(k) + ".bin'',''K" + string(k) + "'') , ...
> save(''M" + string(k) + ".bin'',''M" + string(k) + "'') , ...
> ";
> execstr(s1) ;
>   
> end
> 
> printf("\n\n");
> 
> // difference v1 - v2
> for k = 2 : nbre
> s2 = " ...
> printf(""(eigenvalues) Max delta u%d - u1 = %g\n"",k,abs(max(u" + 
> string(k) + " - u1))) , ...
> printf(""(eigenvectors) Max delta v%d - v1 = %g\n"",k,abs(max(v" + 
> string(k) + " - v1))) , ...
> printf(""(input matrix) Max delta K%d - K1 = %g\n"",k,abs(max(K" + 
> string(k) + " - K1))) , ...
> printf(""(input matrix) Max delta M%d - M1 = %g\n"",k,abs(max(M" + 
> string(k) + " - M1))) , ...
> ";
> execstr(s2) ;
> printf("\n");
> end
> ##"
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -Message d'origine-
> De : users [mailto:users-boun...@lists.scilab.org] De la part de Antoine 
> Monmayrant Envoyé : vendredi 26 juin 2015 10:50 À : International users 
> mailing list for Scilab.
> Objet : Re: [Scilab-users] eigs calculation
> 
> Hi Paul,
> 
> I don't really like a function that gives different answers for the very same 
> input.
> That sounds like a bug to me.
> That being said, from the data you showed, it is not clear that your 
> eigenvector are really different.
> If what you show is just a difference in the norm of the difference between 
> the eigenvalue at iteration 1 and N, that might be OK.
> Indeed, if v is an eigenvector, a.v with a non zero-scalar, is also an 
> eigenvector.
> You should check whether v1 and vN are colinear: if they are, the results are 
> not really different, they just differ by a scaling factor.
> But I would still call it a bug, as a function should always give the same 
> answer when given the same input parameters.
> 
> Cheers,
> 
> Antoine
> 
>  
> Le Jeudi 25 Juin 2015 17:17 CEST, "Carrico, Paul" 
>  a écrit: 
>  
> > Dear all
> > 
> > I'm still working on my "eigs" issue topic and I'm still trying to 
> > understand what's going wrong;
> > 
> > I run a test case :
> > - same function is launched 10 times
> > - each time the input data are recorded (K,M)
> > - for each loop the eigenvalues u and the eigenvectors v are recorded
> > 
> > Then the values of each loop are compared with the values of the loop
> > 1
> > 
> > If K,M,u remains strictly identical, it is not the case for u (the 
> > eigenvectors) ... why ?
> > 
> > I've ever check any initialization issue, but everything seems to be 
> > ok
> > 
> > Paul
> > 
> > PS : the results of this case
> > 
> > Max delta v2 - v1 = 453.857
> > Max delta K2 - K1 = 0
> > Max delta M2 - M1 = 0
> > 
> > Max delta v3 - v1 = 549.214
> > Max delta K3 - K1 = 0
> > Max delta M3 - M1 = 0
> > 
> > Max delta v4 - v1 = 585.95
> > Max delta K4 - K1 = 0
> > Max delta M4 - M1 = 0
> > 
> > Max delta v5 - v1 = 379.702
> > Max delta K5 - K1 = 0
> > Max delta M5 - M1 = 0
> > 
> > Max delta v6 - v1 = 489.844
> > Max delta K6 - K1 = 0
> > Max delta M6 - M1 = 0
> > 
> > Max delta v7 - v1 = 439.221
> > Max delta K7 - K1 = 0
> > Max delta M7 - M1 = 0
> > 
> > Max delta v8 - v1 = 432.406
> > Max delta K8 - K1 = 0
> > Max delta M8 - M1 = 0
> > 
> > Max delta v9 - v1 = 351.752
> > Max delta K9 - K1 = 0
> > Max delta M9 - M1 = 0
> > 
> > Max delta v10 - v1 = 554.515
> > Max delta K10 - K1 = 0
> > Max delta M10 - M1 = 0
> > 
> > -Message d'origine-
> > De : Carrico, Paul
> > Envoyé : mercredi 17 juin 2015 22:18
> > À : International users mailing list for Scilab.
> > Objet : RE: [Scilab-users] eigs calculation
> > 
> > Dear All
> > 
> > Thanks for the answers.
> > 
> > To give more information's on what I'm doing (That's quite new I confess), 
> > I'm performing  a (basic) finite element calculation with beams using 
> > sparse matrix (stiffness matrix K and mass matrix M).
> > [u,v] =
> > eigs(K((ddl_elem+1):$,(ddl_elem+1):$),M((ddl_elem+1):$,(ddl_elem+1):$)
> > ,n,"SM");
> > 
> > Nota: ddl means dof
> > 
> > I'm calculated first the natural 

Re: [Scilab-users] eigs calculation

2015-06-26 Thread Carrico, Paul
U = eigenvalues -> matrix (nx1)
V = eigenvectors -> matrix (nxn)

NB: n = 12 since I'm foccusing of the n first natural frequencies 

Paul

-Message d'origine-
De : users [mailto:users-boun...@lists.scilab.org] De la part de Antoine 
Monmayrant Envoyé : vendredi 26 juin 2015 12:26 À : International users mailing 
list for Scilab.
Objet : Re: [Scilab-users] eigs calculation

 
Le Vendredi 26 Juin 2015 11:16 CEST, "Carrico, Paul" 
 a écrit: 
 
> Hi Antoine,
> 
> Thanks for the comments; In attachment the results of the calculations 
> (note that the modal effective depends on the eigenvectors)
> 
> The calculation for the difference calculations are described herebellow ..

I'm confused, who's who:
u = value or vector
v = value or vector ?

Antoine

> 
> 
> Paul
> 
> ###"
> // prog principal
> nbre = 10;
> for k = 1 : nbre
> printf("\n***\nIteration num %d\n",k);
> s1 = "  ...
> [u" + string(k) + ",v" + string(k) + ",K" + string(k) + ",M" + string(k) 
> + "] = calcul_v() , ...
> [nl,nc] = size(v" + string(k) + ") , ...
> save(''u" + string(k) + ".bin'',''u" + string(k) + "'') , ...
> save(''v" + string(k) + ".bin'',''v" + string(k) + "'') , ...
> clear nl , ...
> clear nc , ...
> save(''K" + string(k) + ".bin'',''K" + string(k) + "'') , ...
> save(''M" + string(k) + ".bin'',''M" + string(k) + "'') , ...
> ";
> execstr(s1) ;
>   
> end
> 
> printf("\n\n");
> 
> // difference v1 - v2
> for k = 2 : nbre
> s2 = " ...
> printf(""(eigenvalues) Max delta u%d - u1 = %g\n"",k,abs(max(u" + 
> string(k) + " - u1))) , ...
> printf(""(eigenvectors) Max delta v%d - v1 = %g\n"",k,abs(max(v" + 
> string(k) + " - v1))) , ...
> printf(""(input matrix) Max delta K%d - K1 = %g\n"",k,abs(max(K" + 
> string(k) + " - K1))) , ...
> printf(""(input matrix) Max delta M%d - M1 = %g\n"",k,abs(max(M" + 
> string(k) + " - M1))) , ...
> ";
> execstr(s2) ;
> printf("\n");
> end
> ##"
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -Message d'origine-
> De : users [mailto:users-boun...@lists.scilab.org] De la part de Antoine 
> Monmayrant Envoyé : vendredi 26 juin 2015 10:50 À : International users 
> mailing list for Scilab.
> Objet : Re: [Scilab-users] eigs calculation
> 
> Hi Paul,
> 
> I don't really like a function that gives different answers for the very same 
> input.
> That sounds like a bug to me.
> That being said, from the data you showed, it is not clear that your 
> eigenvector are really different.
> If what you show is just a difference in the norm of the difference between 
> the eigenvalue at iteration 1 and N, that might be OK.
> Indeed, if v is an eigenvector, a.v with a non zero-scalar, is also an 
> eigenvector.
> You should check whether v1 and vN are colinear: if they are, the results are 
> not really different, they just differ by a scaling factor.
> But I would still call it a bug, as a function should always give the same 
> answer when given the same input parameters.
> 
> Cheers,
> 
> Antoine
> 
>  
> Le Jeudi 25 Juin 2015 17:17 CEST, "Carrico, Paul" 
>  a écrit: 
>  
> > Dear all
> > 
> > I'm still working on my "eigs" issue topic and I'm still trying to 
> > understand what's going wrong;
> > 
> > I run a test case :
> > - same function is launched 10 times
> > - each time the input data are recorded (K,M)
> > - for each loop the eigenvalues u and the eigenvectors v are 
> > recorded
> > 
> > Then the values of each loop are compared with the values of the 
> > loop
> > 1
> > 
> > If K,M,u remains strictly identical, it is not the case for u (the 
> > eigenvectors) ... why ?
> > 
> > I've ever check any initialization issue, but everything seems to be 
> > ok
> > 
> > Paul
> > 
> > PS : the results of this case
> > 
> > Max delta v2 - v1 = 453.857
> > Max delta K2 - K1 = 0
> > Max delta M2 - M1 = 0
> > 
> > Max delta v3 - v1 = 549.214
> > Max delta K3 - K1 = 0
> > Max delta M3 - M1 = 0
> > 
> > Max delta v4 - v1 = 585.95
> > Max delta K4 - K1 = 0
> > Max delta M4 - M1 = 0
> > 
> > Max delta v5 - v1 = 379.702
> > Max delta K5 - K1 = 0
> > Max delta M5 - M1 = 0
> > 
> > Max delta v6 - v1 = 489.844
> > Max delta K6 - K1 = 0
> > Max delta M6 - M1 = 0
> > 
> > Max delta v7 - v1 = 439.221
> > Max delta K7 - K1 = 0
> > Max delta M7 - M1 = 0
> > 
> > Max delta v8 - v1 = 432.406
> > Max delta K8 - K1 = 0
> > Max delta M8 - M1 = 0
> > 
> > Max delta v9 - v1 = 351.752
> > Max delta K9 - K1 = 0
> > Max delta M9 - M1 = 0
> > 
> > Max delta v10 - v1 = 554.515
> > Max delta K10 - K1 = 0
> > Max delta M10 - M1 = 0
> > 
> > -Message d'origine-
> > De : Carrico, Paul
> > Envoyé : mercredi 17 juin 2015 22:18 À : International users mailing 
> > list for Scilab.
> > Objet : RE: [Scilab-users] eigs calculation
> > 
> > Dear All
> > 
> > Thanks for the

Re: [Scilab-users] number od decimals with csvWrite

2015-06-26 Thread Станислав

Hi.
I suppose no need to use the round function. Use csvWrite:

A=rand(3,3);

csvWrite(A, 'file_with_A_data.txt', ' ', '.', "%.2e")

7.26e-01 2.32e-01 8.83e-01
1.99e-01 2.31e-01 6.53e-01
5.44e-01 2.16e-01 3.08e-01

By the way, if you want to use a comma as a decimal mark the fourth 
parameter should be ',':


csvWrite(A, 'file_with_A_data.txt', ' ', ',', "%.2e")


Stanislav


26.06.2015 12:09, Serge Steer пишет:

The simplest way is to use round

A=rand(3,3);
B=round(100*A)/100;

Serge Steer
Le 25/06/2015 22:07, Simone Meroni a écrit :

Hi
I want to write some data and export them with

csvWrite

I need to have no more than 2 decimals for aesthetic reasons.

How can I set the number of decimals?

Thanks,

Simone Meroni


___
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