Re: [Scilab-users] Scilab 6 problem with "Prettify"

2017-09-07 Thread Pierre Vuillemin

Hi Claus,

You need to spot where the 'invalid buffer' message comes from. Adding 
'pause' statements throughout your script may help you (or is there a 
debugging step by step tool? I don't know). Or you may want to comment 
suspicious parts of your code until there is no more error


Do you read data at some point? I would intuitively suspect such a 
message to be related to some data input/data reading operation but I 
may be mistaken.


Besides, I've encountered a similar behaviour where Scilab 6 seems to 
work during the first run of a script but then something goes wrong and 
nothing works quite right anymore (like error messages out of the place) 
until Scilab is restarted. At this point I find this version quite unstable.



Pierre


Le 07/09/2017 à 21:55, Claus Futtrup a écrit :

Hi all

The "Invalid buffer." message becomes even weirder. It is not in the 
list of error messages:

https://help.scilab.org/docs/6.0.0/en_US/error_table.html

I guarantee it's not an error message I've made up myself. The entire 
script does not contain the word "buffer" (or "buffer.") anywhere.


/Claus

On 07-09-2017 21:25, Samuel Gougeon wrote:

Hello Claus,
In Scilab, clear is deleterious. As a first hint, i would try 
commenting it before rerunning  the script.

Best regards
Samuel

Le 06/09/2017 à 21:33, Claus Futtrup a écrit :


Hi there

I've started to use the prettify functions by Pierre Vuillemin. So 
far so good in Scilab 5.5


Now I've started to look into Scilab 6 (not least because graphics 
is much faster), but I get a weird error.


If I start Scilab, first time I execute the code, I get an "Invalid 
buffer." message.


Second time I execute the code then I get a bad message:


--> exec('C:\Users\claus\Documents\Scilab54\z3mfit.sce', -1)
at line93 of executed file 
C:\Users\claus\Documents\Scilab54\z3mfit.sce


'labels_font_size'  ,  3,...
^^
Error: syntax error, unexpected "'", expecting "," or )


When I run my script, the first thing my code does - it clears all 
variables, all graphics and clears console, so it's not "old" stuff 
from previous run that is the problem. Or ???


The "line 93" is part of the default options in Prettify, where it 
says labels_font_size. It looks like this:


default_options  =  struct('title_font_size',   4,...
  'labels_font_size'   ,   3,...
  'thicks_font_size'   ,   2,...
  'num_format' ,   '',...
  'leg_font_size'  ,   3,...
  'line_thickness' ,   2,...
  'xstring_font_size'  ,   2)

Can anyone spot, what is the problem?

P.S. This part of the code is in a section that is controlled by an 
if-statement, and even if I make sure the condition is false (so 
that the Prettify code is not executed), Scilab still spits out this 
error. It's really weird - and even weirder it doesn't get the error 
the first time that the code is executed.


P.S. My entire code is ca. 915 lines long + requires input data, so 
I prefer not to attach it to a post here in the mailing list.


Best regards,

Claus





___
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


Re: [Scilab-users] Scilab 6 problem with "Prettify"

2017-09-07 Thread Pierre Vuillemin
Dear Claus, 

I've not experienced any issue on Scilab 6 so far with this routine. 

If this error shows up even if the code is not executed then the error
may come from elsewhere? I've had some issues with Scilab 6 error
messages pointing out the wrong chunk of code. 

The "invalid buffer" message may indicate that there is a problem during
the first run. I would start by investigating this part. 

Best regards, 

Pierre 

Le 06.09.2017 21:33, Claus Futtrup a écrit :

> Hi there 
> 
> I've started to use the prettify functions by Pierre Vuillemin. So far so 
> good in Scilab 5.5 
> 
> Now I've started to look into Scilab 6 (not least because graphics is much 
> faster), but I get a weird error. 
> 
> If I start Scilab, first time I execute the code, I get an "Invalid buffer." 
> message. 
> 
> Second time I execute the code then I get a bad message: 
> 
> --> exec('C:\Users\claus\Documents\Scilab54\z3mfit.sce', -1)
> at line93 of executed file C:\Users\claus\Documents\Scilab54\z3mfit.sce
> 
> 'labels_font_size'  ,  3,...
> ^^
> Error: syntax error, unexpected "'", expecting "," or ) 
> 
> When I run my script, the first thing my code does - it clears all variables, 
> all graphics and clears console, so it's not "old" stuff from previous run 
> that is the problem. Or ??? 
> 
> The "line 93" is part of the default options in Prettify, where it says 
> labels_font_size. It looks like this:
> 
> default_options = struct('title_font_size'   ,  4,...
> 'labels_font_size'  ,  3,...
> 'thicks_font_size'  ,  2,...
> 'num_format',  '',...
> 'leg_font_size' ,  3,...
> 'line_thickness',  2,...
> 'xstring_font_size' ,  2)
> 
> Can anyone spot, what is the problem? 
> 
> P.S. This part of the code is in a section that is controlled by an 
> if-statement, and even if I make sure the condition is false (so that the 
> Prettify code is not executed), Scilab still spits out this error. It's 
> really weird - and even weirder it doesn't get the error the first time that 
> the code is executed. 
> 
> P.S. My entire code is ca. 915 lines long + requires input data, so I prefer 
> not to attach it to a post here in the mailing list. 
> 
> Best regards, 
> 
> Claus 
> ___
> 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] C gateway with scilab api

2017-03-28 Thread Pierre Vuillemin

Hi all,

I'm trying to call some C code from Scilab. To understand how the scilab 
api is working, I've tried to reproduce the example described here:


https://help.scilab.org/docs/6.0.0/fr_FR/api_scilab_getting_started.html

but it does not work for me. The command

[c,  d]  =  foo6([2,%pi],  [%t,  %f])

displays an error saying that the number of input arguments is wrong, 2 
arguments are expected:


foo6 : Nombre erroné d'argument(s) d'entrée : 2 attendu(s).


Is there an issue in the example or am I missing something? Besides, I 
have experienced a lot of seg fault in the process: is the API or this 
version of Scilab still quite experimental?



NB: I am using Scilab 6 on Ubuntu 16.04.


Best regards,


Pierre



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


Re: [Scilab-users] Replace multiple occurrences of regular expression in string with strsubst

2017-03-27 Thread Pierre Vuillemin

My bad, I didn't see the bug report. Great news though.

Regards,

Pierre


Le 27/03/2017 à 16:43, sgoug...@free.fr a écrit :

- Mail original -

De: "Pierre Vuillemin", Lundi 27 Mars 2017 09:57:01

Hi all,

It seems that when using regular expressions with strsubst, only the
first occurrence is replaced. For instance,

tst_str  = 'This is a cow. A cow is funny.'
out1 = strsubst(tst_str, 'cow', 'rabbit')
out2 = strsubst(tst_str,'/cow/','rabbit','r')
disp(out1) // both occurence are replaced -> ok
disp(out2) // only the first occurence is replaced -> strange?

Is it the intended behaviour?

No, but after years of being pending after the report
http://bugzilla.scilab.org/4276
it was fixed very recently and is already available in the
Nightly Built 6.0 branch:
https://codereview.scilab.org/#/c/19144/

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


Re: [Scilab-users] simple plot function

2017-03-27 Thread Pierre Vuillemin
Hi, 

A dot is missing in the argument of the hyperbolic sin for the division
to be performed element-wise, 

x=0:0.1:1;   
y=exp((x.^4+x.^2-x+(5).^(0.5))/5)+sinh((x.^3+21*x+9) ./
(21*x+6))-3.0;
plot(x,y) 

Regards, 

Pierre 

Le 27.03.2017 13:39, Luciano Andino a écrit :

> Hi, doing a simple plot of
> x in [0,1]
> 
> x=0:0.1:1;
> y=exp((x.^4+x.^2-x+(5).^(0.5))/5)+sinh((x.^3+21*x+9)/(21*x+6))-3.0;
> plot(x,y)
> 
> graphic differs from this online calc:
> 
> https://www.desmos.com/calculator/jehn17mvvb
> 
> Don't know what I am doing wrong,
> 
> thanks in advance
> 
> -- 
> 
> Luciano Andino
> Ing. en Sistemas de Información 
> UTN FRSF
> BMSTU
> 
> ___
> 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] Replace multiple occurrences of regular expression in string with strsubst

2017-03-27 Thread Pierre Vuillemin

Hi all,

It seems that when using regular expressions with strsubst, only the 
first occurrence is replaced. For instance,


tst_str  = 'This is a cow. A cow is funny.'
out1 = strsubst(tst_str, 'cow', 'rabbit')
out2 = strsubst(tst_str,'/cow/','rabbit','r')
disp(out1) // both occurence are replaced -> ok
disp(out2) // only the first occurence is replaced -> strange?

Is it the intended behaviour?

Regards,

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


Re: [Scilab-users] A tool for creating formated tables

2017-03-16 Thread Pierre Vuillemin

Hi Samuel,

Indeed, I know the prettyprint function, the idea behind the function 
tabular was slightly different as it was firstly aimed at displaying 
tables including both string/numerical data in a unified way.


Regards,

Pierre


Le 15/03/2017 à 20:33, Samuel Gougeon a écrit :

Hello Pierre,

Le 15/03/2017 à 18:56, Pierre Vuillemin a écrit :


Hi all,

I've made a little tool for creating formated tables in Scilab. In 
particular, it enables to:


  * display pretty tables in the console,
  * create github-markdown tables,
  * create latex tables.

Source code (the file tabular.sci) and some examples are provided 
here <https://github.com/pivui/scilabTools/tree/master/tabular>. It 
is not fully documented yet but the examples in the README give a 
good overview.


Comments and feedback are welcome.

I will also add the possibility to export matrices to latex (without 
titles or headers).




I did not have a look to your github yet, but do you know prettyprint()?
https://help.scilab.org/docs/6.0.0/en_US/prettyprint.html

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] A tool for creating formated tables

2017-03-15 Thread Pierre Vuillemin

Hi all,

I've made a little tool for creating formated tables in Scilab. In 
particular, it enables to:


 * display pretty tables in the console,
 * create github-markdown tables,
 * create latex tables.

Source code (the file tabular.sci) and some examples are provided here 
. It is not 
fully documented yet but the examples in the README give a good overview.


Comments and feedback are welcome.

I will also add the possibility to export matrices to latex (without 
titles or headers).



Regards,

Pierre

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


Re: [Scilab-users] ?==?utf-8?q? Plots for scientific papers

2017-03-10 Thread Pierre Vuillemin
Hi all, 

* the last version no longer assumes that there is a legend,
* I've added a doc (header) with an example that should clarify the
options. I tend to use structure for options, i.e.

opt.line_thickness = 2 

prettify(h, opt) 

* now, the z-axis should also be modified.

Regards, 

Pierre 

nb: again, the last version is on my github [1]. 

Le 09.03.2017 20:10, Jens Simon Strom a écrit :

> Hallo Pierre,
> prettyfy is great. It will save many people a lot of time and trouble. I do 
> not often use a legend. Leaving it out produces an error and using an empty 
> one looks ugly. So that's my suggestion.
> Kind regards
> Jens
> --
> Am 08.03.2017 18:28, schrieb Pierre Vuillemin: 
> 
> I may complete the script over time if you have some suggestions. 
> 
> Until then, I don't see any difference when changing the value of the 
> anti-aliasing option, does someone know if it is still functional? 
> 
> Regards, 
> 
> Pierre 
> Le 08/03/2017 à 16:29, Claus Futtrup a écrit : 
> Hi Pierre and Antoine
> 
> Thank you very much for your help. This is very inspiring and encouraging.
> 
> Best regards,
> Claus
> 
> On 08-03-2017 11:41, Pierre Vuillemin wrote: Following Antoine's idea, find 
> enclosed an example on how you can automate the process of improving your 
> plots. This is obviously incomplete but it gives a general idea. 
> 
> Hope it helps, 
> 
> Pierre 
> 
> Le 08.03.2017 10:08, Antoine Monmayrant a écrit : 
> It's definetly possible to do it. 
> In my group, we usually: 
> - set decent default values for the default figure ( hd=gdf() ): 
> increase font size, ... 
> - fix the ticks madness (ie replace [0. 0.167 0.333 0.5 0.667 0.833 1. 
> ] ticks by [0. 0.25 0.5 0.75 1.]) 
> - use the latex rendering for all the text, including ticks labels: 
> - for ticks¹, just prepend & append "$" to the labels: ["0"; "0.25"; 
> "0.5"; "0.75"; "1"]->["$0$"; "$0.25$"; "$0.5$"; "$0.75$"; "$1$"]. 
> - for text, use "$\text{" and "}$" : "$\text{Your fancy text rendered 
> in Latex: \lambda^\beta}$" 
> - Export in a vectorial format, I prefer svg. 
> - Apply some cosmetic changes, add arrows, "(a)", "(b)", ... using Inkscape 
> - Generate a pdf version. 
> 
> Hope it helps, 
> 
> Antoine 
> ¹ We have a script to clean up the ticks: it sets a decent number of 
> ticks, and automate the prepend/append of "$". 
> 
> Le Mardi, Mars 07, 2017 20:35 CET, Claus Futtrup <cfutt...@gmail.com> a 
> écrit: 
> 
> Hi 
> 
> I'm using Python matplotlib for some graphs for scientific papers. The 
> reason is that the font and all seems to fit very well with the LaTeX 
> document. 
> 
> I know that Scilab can accept MathML (or LaTeX) expressions. Is there a 
> simple way to configure Scilab for similar high-quality plots? ... I'd 
> like all text to be nice looking, i.e. the title, the x-axis and y-axis 
> labels, the legend, etc. 
> 
> Best regards, 
> 
> Claus 
> 
> ___ 
> 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

___
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 

 

Links:
--
[1]
https://github.com/pivui/scilabTools/blob/master/prettify/prettify.sci___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ?==?utf-8?q? Plots for scientific papers

2017-03-09 Thread Pierre Vuillemin
Hi Claus, 

find enclosed an updated version (now adequately called _prettify_
instead of _prettyfy_...). Besides, subsequent evolutions will be posted
here [1]. 

You can email me directly if you find other issues. 

Hope it helps, 

Pierre 

Le 08.03.2017 21:51, Claus Futtrup a écrit :

> Hi Pierre, et al
> 
> Using gcf() doesn't solve my problem. I get:
> 
> !--error 999 
> 'font_size' property does not exist for this handle.
> at line   4 of function generic_i_h called by :  
> at line   2 of function %s_i_h called by :  
> at line  52 of function prettyfy called by :  
> prettyfy(gt);
> at line1556 of exec file called by :
> exec('C:\Users\claus\Documents\Scilab54\z3fit.sce', -1)
> 
> This is what the code looks like now:
> 
> scf();
> drawlater(); 
> plot(shortxlist,shortylist,'-b'); // Plot smoothed data
> plot(shortxlist,blf1_array(boollist,2),'-r'); // Plot original data 
> t = gca();
> set(t,"grid",[1 1]); 
> xgrid(color("grey70"));
> xtitle("Bl density plot","Bl-value +/- 0.01% range","Quantity / Density"); 
> drawnow();
> gt = gcf(); 
> prettyfy(gt);
> 
> Actually the plot came up with nice title, axis text, etc. ... I don't know 
> what makes the prettyfy function crash on me ... Is it because the plot 
> doesn't have a legend?
> 
> As mentioned, some error handling could do good. :-)
> 
> Best regards,
> Claus
> 
> On 08-03-2017 21:24, Claus Futtrup wrote: 
> Hi Pierre
> 
>> I may complete the script over time if you have some suggestions.
> 
> Let me work with it over some time ... the first attempt ended like this:
> 
> !--error 999 
> 'font_size' property does not exist for this handle.
> at line   7 of function %h_set called by :  
> at line   4 of function generic_i_h called by :  
> at line   2 of function %s_i_h called by :  
> at line  36 of function prettyfy called by :  
> prettyfy(t);
> at line1555 of exec file called by :
> exec('C:\xx\Scilab54\z3fit.sce', -1)
> 
> Here's the code which generated above error:
> 
> scf();
> drawlater(); 
> plot(shortxlist,shortylist,'-b'); // Plot smoothed data
> plot(shortxlist,blf1_array(boollist,2),'-r'); // Plot original data 
> t = gca();
> set(t,"grid",[1 1]); 
> xgrid(color("grey70"));
> xtitle("Bl density plot","Bl-value +/- 0.01% range","Quantity / Density"); 
> drawnow();
> prettyfy(t);
> 
> I'm not sure, but could it be that my graphs are created in a different way? 
> I use scf() and gca() instead of gcf() ...
> 
> Instead of writing "prettyfy(t)" ... could I just feed gcf() directly into 
> prettyfy ??
> 
> BTW, I'm using Scilab 5.5.0 at the moment.
> 
> Best regards,
> Claus
> 
> On 08-03-2017 18:28, Pierre Vuillemin wrote: 
> 
> I may complete the script over time if you have some suggestions. 
> 
> Until then, I don't see any difference when changing the value of the 
> anti-aliasing option, does someone know if it is still functional? 
> 
> Regards, 
> 
> Pierre 
> Le 08/03/2017 à 16:29, Claus Futtrup a écrit : 
> Hi Pierre and Antoine
> 
> Thank you very much for your help. This is very inspiring and encouraging.
> 
> Best regards,
> Claus
> 
> On 08-03-2017 11:41, Pierre Vuillemin wrote: Following Antoine's idea, find 
> enclosed an example on how you can automate the process of improving your 
> plots. This is obviously incomplete but it gives a general idea. 
> 
> Hope it helps, 
> 
> Pierre 
> 
> Le 08.03.2017 10:08, Antoine Monmayrant a écrit : 
> It's definetly possible to do it. 
> In my group, we usually: 
> - set decent default values for the default figure ( hd=gdf() ): 
> increase font size, ... 
> - fix the ticks madness (ie replace [0. 0.167 0.333 0.5 0.667 0.833 1. 
> ] ticks by [0. 0.25 0.5 0.75 1.]) 
> - use the latex rendering for all the text, including ticks labels: 
> - for ticks¹, just prepend & append "$" to the labels: ["0"; "0.25"; 
> "0.5"; "0.75"; "1"]->["$0$"; "$0.25$"; "$0.5$"; "$0.75$"; "$1$"]. 
> - for text, use "$\text{" and "}$" : "$\text{Your fancy text rendered 
> in Latex: \lambda^\beta}$" 
> - Export in a vectorial format, I prefer svg. 
> - Apply some cosmetic changes, add arrows, "(a)", "(b)", ... using Inkscape 
> - Generate a pdf version. 
> 
> Hope it helps, 
> 
> Antoine 
> ¹ We have a script to clean up the ticks: it sets a decent number of 
> ticks, and automate the prepend/append of "$&q

Re: [Scilab-users] ?==?utf-8?q? Plots for scientific papers

2017-03-08 Thread Pierre Vuillemin

I may complete the script over time if you have some suggestions.

Until then, I don't see any difference when changing the value of the 
anti-aliasing option, does someone know if it is still functional?


Regards,

Pierre


Le 08/03/2017 à 16:29, Claus Futtrup a écrit :

Hi Pierre and Antoine

Thank you very much for your help. This is very inspiring and encouraging.

Best regards,
Claus

On 08-03-2017 11:41, Pierre Vuillemin wrote:
Following Antoine's idea, find enclosed an example on how you can 
automate the process of improving your plots. This is obviously 
incomplete but it gives a general idea.


Hope it helps,

Pierre

Le 08.03.2017 10:08, Antoine Monmayrant a écrit :

It's definetly possible to do it.
In my group, we usually:
- set decent default values for the default figure ( hd=gdf() ):
increase font size, ...
- fix the ticks madness (ie replace [0. 0.167 0.333 0.5 0.667 0.833 1.
] ticks by [0. 0.25 0.5 0.75 1.])
- use the latex rendering for all the text, including ticks labels:
- for ticks¹, just prepend & append "$" to the labels: ["0"; "0.25";
"0.5"; "0.75"; "1"]->["$0$"; "$0.25$"; "$0.5$"; "$0.75$"; "$1$"].
- for text, use "$\text{" and "}$" : "$\text{Your fancy text rendered
in Latex: \lambda^\beta}$"
- Export in a vectorial format, I prefer svg.
- Apply some cosmetic changes, add arrows, "(a)", "(b)", ... using 
Inkscape

- Generate a pdf version.


Hope it helps,

Antoine
¹ We have a script to clean up the ticks: it sets a decent number of
ticks, and automate the prepend/append of "$".


Le Mardi, Mars 07, 2017 20:35 CET, Claus Futtrup 
<cfutt...@gmail.com> a écrit:



Hi

I'm using Python matplotlib for some graphs for scientific papers. The
reason is that the font and all seems to fit very well with the LaTeX
document.

I know that Scilab can accept MathML (or LaTeX) expressions. Is 
there a

simple way to configure Scilab for similar high-quality plots? ... I'd
like all text to be nice looking, i.e. the title, the x-axis and 
y-axis

labels, the legend, etc.

Best regards,

Claus

___
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





___
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] ?==?utf-8?q? Plots for scientific papers

2017-03-08 Thread Pierre Vuillemin
Following Antoine's idea, find enclosed an example on how you can 
automate the process of improving your plots. This is obviously 
incomplete but it gives a general idea.


Hope it helps,

Pierre

Le 08.03.2017 10:08, Antoine Monmayrant a écrit :

It's definetly possible to do it.
In my group, we usually:
- set decent default values for the default figure ( hd=gdf() ):
increase font size, ...
- fix the ticks madness (ie replace [0. 0.167 0.333 0.5 0.667 0.833 1.
] ticks by [0. 0.25 0.5 0.75 1.])
- use the latex rendering for all the text, including ticks labels:
- for ticks¹, just prepend & append "$" to the labels: ["0"; "0.25";
"0.5"; "0.75"; "1"]->["$0$"; "$0.25$"; "$0.5$"; "$0.75$"; "$1$"].
- for text, use "$\text{" and "}$" : "$\text{Your fancy text rendered
in Latex: \lambda^\beta}$"
- Export in a vectorial format, I prefer svg.
- Apply some cosmetic changes, add arrows, "(a)", "(b)", ... using 
Inkscape

- Generate a pdf version.


Hope it helps,

Antoine
¹ We have a script to clean up the ticks: it sets a decent number of
ticks, and automate the prepend/append of "$".


Le Mardi, Mars 07, 2017 20:35 CET, Claus Futtrup  a 
écrit:



Hi

I'm using Python matplotlib for some graphs for scientific papers. The
reason is that the font and all seems to fit very well with the LaTeX
document.

I know that Scilab can accept MathML (or LaTeX) expressions. Is there 
a

simple way to configure Scilab for similar high-quality plots? ... I'd
like all text to be nice looking, i.e. the title, the x-axis and 
y-axis

labels, the legend, etc.

Best regards,

Claus

___
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
clear
clf()
// The figure
n = 100;
x = linspace(0,2*%pi,n);
y = sin(x);
z = cos(x);
plot(x,y,x,z)
h = gcf();
title('Figure of $f_1(x)$ and $f_2(x)$')
xlabel('$x$ (rad)')
ylabel('$y$')
legend('$f_1(x) = sin(x)$ (my favourite)','$f_2(x) = cos(x)$')
//
function prettyfy(f)
   // Your custom settings
   title_font_size   = 4
   labels_font_size  = 3
   thicks_font_size  = 2
   leg_font_size = 3
   line_thickness= 2
   // Some internal functions
   function str = latexify(str)
  // Adds $ at the beginning and the end of a matrix of strings
  for i = 1:size(str,1)
 str(i) = '$' + wrap_in_text(str(i)) + '$'
  end
   endfunction
   function out_str = wrap_in_text(str)
  // In a string containing normal text and latex expressions between $, 
this
  // routines wraps the text part inside \text{.} macros
  // '$f(x) = sin(x)$ is a nice function' --> 'f(x) = sin(x)\text{ is a 
nice function}'
  str   = stripblanks(str)
  T = tokens(str, '$')
  if part(str,1) ~= '$' then
 start = 1
  else
 start = 2
  end
  for i = start:2:size(T,1)
 T(i,:) = '\text{'+T(i,:)+'}'
  end
  out_str = ''
  for i = 1:size(T,1)
 out_str = out_str + T(i,:)
  end
   endfunction   
   // Axis thicks
   ax= f.children
   ax.font_size  = thicks_font_size
   ax.x_ticks.labels = latexify(ax.x_ticks.labels)
   ax.y_ticks.labels = latexify(ax.y_ticks.labels)
   // Axis labels
   xl= ax.x_label
   xl.font_size  = labels_font_size
   xl.text   = latexify(xl.text)
   yl= ax.y_label
   yl.font_size  = labels_font_size
   yl.text   = latexify(yl.text)
   // Title
   T = ax.title
   T.text= latexify(T.text)
   T.font_size   = title_font_size
   // Legend
   leg   = ax.children(1)
   leg.font_size = leg_font_size
   leg.text  = latexify(leg.text)
   for i = 1:length(leg.links)
  leg.links(i).thickness = line_thickness
   end

endfunction
prettyfy(h)
xs2pdf(h,'~/test.pdf')
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Extraction of unusual fields of custom mlist in Scilab 6

2017-03-07 Thread Pierre Vuillemin

Hi all,

I am encountering some difficulties with overloading in Scilab 6, and 
I'm wondering if this is a bug or not.


Consider the following example,

a = mlist(['mytype']);
b = mlist(['myothertype']);
function out = %mytype_e(varargin)
   var   = varargin($);
   field = varargin(1);
   disp(typeof(field))
   out = [];
endfunction
a(b);

It defines two objects 'a' and 'b' of types 'mytype' and 'myothertype'. 
The extraction is overloaded for 'mytype' and displays the type of the 
field that is meant to be extracted.

At the end, I try to extract 'b' from 'a'.

In Scilab 5.5, 'b' is actually passed to the overloading function and 
'myothertype' is displayed by 'a(b)'.
Scilab 6 behaves differently and 'field' in the overloading function is 
a string equal to 'myothertype'.



Best regards,

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


Re: [Scilab-users] Matlab vs Scilab perf

2017-03-04 Thread Pierre Vuillemin
Concerning my assertion that Python outshines Scilab & co in many other 
areas,


 * being a general purpose language, I feel that Python has a broader
   range of application. For instance, for creating a web-app, Scilab
   would certainly not be my first choice, while Python is commonly
   used for that purpose.
 * Python enables to write object-oriented code and has some features
   from functional programming that are quite nice. While Matlab and
   Octave have some "solid" OO features (at least, its enough for what
   I'm doing with it), Scilab is lacking with respect to this point.
   For functional programming, all other environment are far behind
   what Python has to offer. For instance I find that expressions as

   stripped_list  =  [line.strip()  for  line  in  line_list  if  line  !=  
""]

   are really elegant and readable. More generally, manipulating lists
   in python is made really easy.
   I really enjoy lists in Scilab. They feel more coherent to me than
   cells in Matlab, but I wish they had more python-like features.

 * I feel that interfacing with other languages is easier with Python
   than with Scilab/Matlab/Octave.
 * Packages, modules and namespaces enable to create very clear structures.

Besides, I could not agree more with you concerning bad 
syntaxes/redundancy. Having a coherent environment is important.


A step towards this goal may be to update and complete the code 
convention for Scilab 
 
in a similar fashion to Python PEP 
?


Regards,

Pierre

Le 02/03/2017 à 23:23, Samuel Gougeon a écrit :

Hello Ricardo,

Le 02/03/2017 à 19:33, Ricardo Fabbri a écrit :

Speaking from experience:

It is worth mentioning that in many ways performance is not critical
for a "lab" language like Scilab or Matlab. It is just an extremely
simple language to test concepts and algorithms at a very small scale
of granularity. The real crucial factor for Scilab or Matlab is the
GUI for exploring data and developing algorithms interactively. Once
you have a working solution, you'll fit it inside a bigger and more
relevant
system by porting promptly to a language like C++ for scalability and 
speed.


Just use Scilab for what its worth, don't obsess with speed, even
though it is important.


I agree: Matlab, Scilab, Octave, IDL, GDL.. Yorick etc were and are 
still first made for prototyping, not for speed. This is why they were 
back to interpreted -- and so slower -- languages.
But they should not have any handicapping snail instructions for 
common frequently used ones like scf(). Loosing time gained with an 
easy language avoiding to declare each object type and to compile and 
link the whole thing each time that we change a semicolon in the 
code... would be meaningless.


So yes, i definitely agree: it is a matter or ergonomic for GUIs but 
also and first for the language (regular namings, rational order of 
arguments, etc) that make it easy to learn and use. This is somewhat 
why i never really got inside python (and sciPy). I felt its syntax 
not straightforward to learn, even for simple things. Same thing for 
R. And it's always the same feeling when i try to compare results from 
these various languages -- including javascript --, for instance to 
extend Scilab or debug it, seeing usages or conventions the most used 
elsewhere. Each time, it is quite harder for me to find and understand 
the relevant syntax with Python and R, while for instance i find 
javascript more intuitive.
This is why i don't know much about Python. When Pierre writes "Python 
outshines Scilab/Octave/Matlab in many other areas.", i would be 
interested to know more about that.


I agree with you, Pierre, about the whole environment. This is why, on 
this aspect, we could have a specific discussion about which modules 
-- with which components -- should rather compose "Scilab core", and 
which features could be distributed rather on ATOMS. I am not 
convinced that the current "Scilab core" composition is optimal. IMO, 
it is quite unbalanced by historical or particular influences.


As a conclusion, i think that introducing non-optimal syntaxes or 
duplicates etc in the language hurts much more than introducing a 
quite slow algorithm. Simply because the algorithm can be changed 
later without breaking anything, while introducing badly designed 
syntaxes or usages is much harder to manage afterwards, and impedes 
much more learning, using and maintaining the language.


Best regards
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] Arguments of functions in Scilab

2017-03-04 Thread Pierre Vuillemin

Hi all,

I'm a bit confused by functions in Scilab and specifically the way they 
handle their arguments. For instance, in the following code


deff('g(x)','disp(x)');
g; // produces an error saying x is not defined
x = 1;
g; // call the function g and displays x...

leads to two questions,

 * the function g is called each time, shouldn't it be only displayed?
 * the second call 'works' and display x, even if the argument of the
   function has not been provided.  I've read the page concerning
   scoping of variables
    in
   Scilab, but shouldn't it says that the function was expecting 1
   argument?

This feels a bit unsafe to me, I'm wondering what is the reason behind 
this choice?


Best regards,

Pierre

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


Re: [Scilab-users] Matlab vs Scilab perf

2017-03-02 Thread Pierre Vuillemin

My 2 cents,

I think that the main advantage of Scilab/Octave/Matlab in comparison to 
other environments is that they gather various tools in a (somewhat) 
coherent bundle. I think that most users won't need to look for another 
library to do what they want as the most common features are already in 
the environment.


Python does it too with Scipy, but in some domains (e.g. control theory, 
simulink), the features offered by python are far behind what can be 
done in Matlab (and to a lesser extent in Scilab).
Besides, Python being a general programming language, some operations 
feels less natural than with Scilab/Octave/Matlab. For instance, I feel 
that linear algebra quickly becomes unreadable in Python: A*B*C becoming 
A.dot(B.dot(C)) or A @ B @ C 

Conversely, Python outshines Scilab/Octave/Matlab in many other areas.

Concerning speed, while I agree that this is often not that important, 
the Julia Language has demonstrated that it is not necessarily 
unreachable for a "high level language". I guess it mainly relies on the 
performance of the JIT compiler at some point.
I remember reading that Scilab 6 should have a JIT compiler, but I might 
be mistaken?


Also, I am not convinced that Scilab/Octave/Matlab are limited only to 
prototype small algorithms/projects. The main reason being that a lot of 
people won't port their codes to a compiled language because it 
represents way to much work...


Pierre

Le 02/03/2017 à 19:55, Amanda Osvaldo a écrit :

But professor Ricardo.

If it's possible to do the same with python, including the GUI, 
considering the technical issues about hardware consumption and 
scalability. So why to use MatLab, SciLAB or even Octave?


It's not smarter to do all in python and finish the prototype and the 
"main project" with almost half of time and effort?


-- Amanda Osvaldo

On Thu, 2017-03-02 at 15:33 -0300, Ricardo Fabbri wrote:

Speaking from experience:

It is worth mentioning that in many ways performance is not critical
for a "lab" language like Scilab or Matlab. It is just an extremely
simple language to test concepts and algorithms at a very small scale
of granularity. The real crucial factor for Scilab or Matlab is the
GUI for exploring data and developing algorithms interactively. Once
you have a working solution, you'll fit it inside a bigger and more
relevant
system by porting promptly to a language like C++ for scalability and speed.

Just use Scilab for what its worth, don't obsess with speed, even
though it is important.

Best,

--
Dr Ricardo Fabbri
Professor of Computer Engineering
GNU/Linux registered user #175401
pt.wikipedia.org/wiki/IPRJ
labmacambira.sf.net
rfabbri.github.io


On Thu, Mar 2, 2017 at 2:00 PM, Samuel Gougeon > wrote:
Le 02/03/2017 à 16:29, Michael Benguigui a écrit : Hi all, As a 
Scilab user, I am currently fighting to reach Matlab performance..My 
current scilab program takes 4x more than my matlab's vesion. Here 
are some instructions requiring some optimizations.. If you have an 
idea... thanks a lot! All times are cumulative times after the 
execution (iterations) I used the Matlab and Scilab profilers 
Congratulations for using the new Scilab profiler :) Could you post 
please the file of results? It is indeed hard to answer without 
having more information either on a runnable part of your code, or 
about results you got with the profiler. Regards 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



___
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] Strange behaviour of the auto-indent ctrl + i

2017-02-24 Thread Pierre Vuillemin

Hello all,

I've just realised that block-comments are now available in Scilab 6 and 
I find it quite convenient. I've noticed strange behaviour when using 
the auto-indent tool ctrl + i in scinote though.


For instance with this code



// Author : Pierre Vuillemin (2017)
// License : GNU GPL

function problem = sopi_max(fun, varargin)
   /*
   Creates a maximisation problem.

   Calling Sequence
  problem = sopi_max(fun)
  problem = sopi_max(fun, c1, ..., cn)

   Parameters
  fun  : the objective function (sopiVar)
  ci   : constraints (sopiCst or list of sopiCst)
  problem  : the optimisation problem (sopiPro)

   See also
  sopi_var
  sopi_min
  sopi_solve
  sopi_example
   */
   problem = sopi_min(-fun, varargin(:))
endfunction


the auto-ident tool adds strange indentation to the endfunction + it 
suppress the indentation of the text withing the block comment. 
Shouldn't it behave as if // were used?


Regards,

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


[Scilab-users] About some changes in Scilab 6

2017-02-16 Thread Pierre Vuillemin

Hi all,

Congratulations to Scilab team for the release, it looks very promising!


I have begun to test the compatibility of some of my tools with Scilab 6 
and I have some questions:


   - the way libraries are handled seems to have changed with Scilab 6,
   and the example provided in 'help lib' does not work anymore,

   //define some functions
   function z=myplus(x, y)
  z = x + y
   endfunction

   function z=yourplus(x, y)
  x = x - y
   endfunction

   //create the *.bin files in libdir
   libdir = TMPDIR;
   save(libdir + '/myplus.bin', 'myplus');
   save(libdir + '/yourplus.bin', 'yourplus');

   //create the name file
   mputl(['myplus';'yourplus'],TMPDIR+'/names');

   //build the library containing myplus and yourplus
   mylibfoo = lib(libdir+'/');

   The above code says that the path is not a path to a valid library.
   Could someone explain what 'lib' is expecting? (I would like to
   avoid using 'genlib' as it does not recursively goes through
   subdirectories).


   - when 'error' is called within a function that overload the
   behaviour for some object, then the error message is not displayed, e.g.

   a = mlist(['myType']);
   function %myType_e(varargin)
   error('My error msg')
   endfunction
   a(1)


   only says that the operation is not defined for this type without
   displaying 'My error msg'.


   - I'm not sure that this is specific to Scilab 6, but I've noticed a
   large difference in performance for solving linear systems A*x = b
   in comparison to Octave and Matlab. For instance,

   n = 100;
   N = 1000;
   T = 0;
   for i = 1:n
   A = rand(N,N);
   b = rand(N,1);
   tic();
   x = A\b;
   T = T + toc();
   end
   disp(T/n)


   is (significantly) slower with Scilab (binaries for linux 64bits)
   than with Octave. Is it due to the way the underlying lapack library
   is compiled?


   - In Scilab 5, given a variable 'x', the expression

   x = clear('x')


   was allowed and would clean the variable 'x'. Used together with
   'resume' in a function, that allowed to clean variables from the
   above environment. While it might not be a very safe coding
   practice, is there a way to reproduce this behaviour in Scilab 6 ?

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


Re: [Scilab-users] Examples of linear optimisation

2017-02-13 Thread Pierre Vuillemin
Hi Paul, 

You are right, given the timing, this seems to be a good idea to make it
work on Scilab 6.0. I'll do that. 

Thank you, 

Best regards, 

Pierre 

Le 13.02.2017 09:05, Paul Bignier a écrit :

> Hello Pierre,
> 
> Just a remark: you may want to make Sopi available for Scilab 6.0 (you can 
> download a nightly build [2]).
> "-->exec builder.sce" yielded an error on function save() as it takes strings 
> as arguments now.
> 
> Best regards,
> Paul
> 
> On 02/10/2017 06:09 PM, Pierre Vuillemin wrote: 
> 
>> Hi all, 
>> 
>> I'm developing a 'modeling tool' for easing optimisation in Scilab: the Sopi 
>> toolbox [1] 
>> 
>> At the moment, it supports (dense) linear optimisation problems and I have 
>> added the examples from 
>> 
>> https://wiki.scilab.org/Linear%20Programming%20Examples%20in%20Scilab 
>> 
>> in the demos. 
>> 
>> I am quite interested in some feedbacks if you have any. 
>> 
>> Best regards, 
>> 
>> Pierre Vuillemin 
>> 
>> ___
>> users mailing list
>> users@lists.scilab.org
>> http://lists.scilab.org/mailman/listinfo/users
> 
> -- 
> Paul BIGNIER
> Development engineer
> ---
> Scilab Enterprises
> 143bis rue Yves Le Coz - 78000 Versailles, France
> Phone: +33.1.80.77.04.68
> http://www.scilab-enterprises.com
> 
> ___
> users mailing list
> users@lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

 

Links:
--
[1] https://atoms.scilab.org/toolboxes/sopi/0.1.2
[2] http://www.scilab.org/en/development/nightly_builds/branch60___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Examples of linear optimisation

2017-02-10 Thread Pierre Vuillemin

Hi all,

I'm developing a 'modeling tool' for easing optimisation in Scilab: the 
Sopi toolbox <https://atoms.scilab.org/toolboxes/sopi/0.1.2>


At the moment, it supports (dense) linear optimisation problems and I 
have added the examples from


https://wiki.scilab.org/Linear%20Programming%20Examples%20in%20Scilab

in the demos.

I am quite interested in some feedbacks if you have any.


Best regards,

Pierre Vuillemin

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


[Scilab-users] COMPleib library for Scilab

2017-01-21 Thread Pierre Vuillemin

Hi all,

If you are interested in control or LTI model reduction, I've ported 
the COMPleib library (see http://www.complib.de/ for further info) to 
Scilab. You can find it here: 
https://github.com/pivui/scilabTools/tree/master/COMPleib


I've not tested all the models hence some issues might remains. Let me 
know if you find a problem.



On a side note, Scilab seems to have some troubles to plot the bode 
diagrams for some "large" models, for instance with the CDP model,


[A,B1,B,C1,C,D11,D12,D21,nx,nw,nu,nz,ny]=COMPleib('CDP');
H = syslin('c', A,B,C,D21)
gainplot(H)

returns

!--error 264
Valeur erronée de l'argument -9808211 : Ne doit pas contenir de NaN ou 
Inf.

at line 123 of function calfrq called by :
at line  73 of function repfreq called by :
at line  28 of function gainplot cale by :



Regards,

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


Re: [Scilab-users] Anonymous functions

2017-01-20 Thread Pierre Vuillemin

Hi Samuel,

Indeed, the behaviour I seek to reproduce is similar to what could be 
done with a global variable. Yet I would avoid to resort to global 
variables.


From what I've understand about variables scoping in Scilab 
(https://wiki.scilab.org/howto/global%20and%20local%20variables), 
variables from the above level are only replaced/copied locally when 
needed, e.g.


function outer()
  a = 1
function inner()
  disp(a) // a has the value of the outer function
  a = 2   // now a copy is made and a is locally equal to 2
endfunction
  inner()
  disp(a) // a has kept its initial value of 1
endfunction


Hence I guess that the fact that a = 1 in the scope of the outer 
function is stored somewhere so that Scilab can retrieve that 
information when needed. I'm wondering how it works internally and 
whether I could use this to create generic lambda function?


I'm aware that this cannot be done solely in Scilab but requires to 
fiddle with the C interface, but I'm curious to experiment.



Regards,

Pierre


Le 17.01.2017 14:21, Samuel Gougeon a écrit :

Le 17/01/2017 11:46, Pierre Vuillemin a écrit :
I have actually implemented a similar solution (in the previous link) 
except that the data are stored in some list. This leads to anonymous 
functions that behaves as in Matlab, i.e. the data of the function is 
instantiated when the function is created.


In python, the value of the data 'a' is instantiated when the function 
is evaluated. Therefore, if the data 'a' changes, the function 
changes.


Here I could make something like

deff('y=f(x)','y = a*x')

but then the function will get the value of the variable 'a' of the 
current namespace, e.g.


a = 1
function outer(x)
 a = 2
 disp(f(1))
endfunction

f(1) // will give 1
outer(1) // will give 2
a = 3
f(1) // will give 3
outer(1) // will give 2

In this example, I would like f(1) to behave identically independently 
of its position.


If i understand correctly your query, the global space is unique and
aims to allow that:
deff('y=f(x)','global a; y = a*x')

This requires the only variable "a" you want to consider been declared
"global a" before some calling point. Actually, i don't see how to
refer to a unique "a" without telling to Scilab which one it must be.

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


Re: [Scilab-users] Anonymous functions

2017-01-17 Thread Pierre Vuillemin
I have actually implemented a similar solution (in the previous link) 
except that the data are stored in some list. This leads to anonymous 
functions that behaves as in Matlab, i.e. the data of the function is 
instantiated when the function is created.


In python, the value of the data 'a' is instantiated when the function 
is evaluated. Therefore, if the data 'a' changes, the function changes.


Here I could make something like

deff('y=f(x)','y = a*x')

but then the function will get the value of the variable 'a' of the 
current namespace, e.g.


a = 1
function outer(x)
 a = 2
 disp(f(1))
endfunction

f(1) // will give 1
outer(1) // will give 2
a = 3
f(1) // will give 3
outer(1) // will give 2

In this example, I would like f(1) to behave identically independently 
of its position.


Achieving that boils down to be able to refer to a specific variable in 
a specific namespace of Scilab (a kind of pointer I guess), but I'm not 
sure this is possible?



Le 17.01.2017 10:38, Serge Steer a écrit :

A partial solution should be
deff("y=f(x)","a="+sci2exp(a,0)+";y=a*x")

but it may cause numerical problem as a is formatted
Regards

Serge Steer
On 17/01/2017 08:23, Pierre Vuillemin wrote:

Hi all,

I am trying to reproduce the behaviour of anonymous function in Scilab 
(see the code in lambdaFun here: 
https://github.com/pivui/scilabTools).


At the moment, it works like in Matlab, for instance:

a = eye(3,3);
lambda 'f(x) = a*x' // the name of the lambda function will be f
a = rand(3,3)   // the value of 'a' is saved in the lambda 
function when it is created

f(ones(3,1))// gives [1,1,1]'

I would like to emulate the behaviour of lambda function of python as 
well. In that case, 'a' should change when the initial variable 
changes, for instance


a = 2
f = lambda : a
def fun():
  a = 4
  return f
a = 3
f()   // should return 3
fun() // should return 3 -> it does not take the variable 'a' in the 
function namespace


I need to remember where the value or a is stored, I don't know if it 
is possible?


Regards,

Pierre
___
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] Anonymous functions

2017-01-17 Thread Pierre Vuillemin

Hi all,

I am trying to reproduce the behaviour of anonymous function in Scilab 
(see the code in lambdaFun here: https://github.com/pivui/scilabTools).


At the moment, it works like in Matlab, for instance:

a = eye(3,3);
lambda 'f(x) = a*x' // the name of the lambda function will be f
a = rand(3,3)   // the value of 'a' is saved in the lambda function 
when it is created

f(ones(3,1))// gives [1,1,1]'

I would like to emulate the behaviour of lambda function of python as 
well. In that case, 'a' should change when the initial variable changes, 
for instance


a = 2
f = lambda : a
def fun():
  a = 4
  return f
a = 3
f()   // should return 3
fun() // should return 3 -> it does not take the variable 'a' in the 
function namespace


I need to remember where the value or a is stored, I don't know if it is 
possible?


Regards,

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


Re: [Scilab-users] Optim & NelderMead use [closed]

2017-01-16 Thread Pierre Vuillemin
Hi Paul,

You should be careful when using the square root function as it is not
differentiable at 0 (cf the attached file which illustrates this point
in your case). This will leads to issues and prevent optim from "really"
(in a sound way) converging towards the solution. 

To address the issue, you can 

- reformulate your objective function so that it is smooth near the
solution (you will still have an issue at 0 where g is not
differentiable though), 

- use order 0 methods (still, some of them might fail on non-smooth
optimisation problems as the minimum might be very "narrow") 

- dig into non-smooth optimisation (see e.g.
http://napsu.karmitsa.fi/nso/)

Regards,

Pierre 

Le 16.01.2017 10:30, Carrico, Paul a écrit :

> Hi all 
> 
> After  performing tests (and modifying the target function as it should have 
> been done first), I can better understand how to use 'optim' and 'Neldermead' 
> procedures. 
> 
> For my needs the mean flags are :
> 
> -  Step h in numderivative à usefull reading as "EE 221 Numerical 
> Computing" Scott Hudson
> 
> -  The threshold epsg in optim (%eps is the default value - such high 
> accuracy is not necessary for my application - furthermore using a value such 
> as 1e-5 leads to err=1 that is correct for checking)
> 
> -  Ditto for Nelder-Mead and '-tolfunrelative' & '-tolxrelative'
> 
> Now it works fine :-)
> 
> Thanks all for the support
> 
> Paul
> 
> #
> 
> mode(0)
> 
> clear
> 
> global count_use;
> 
> count_use = 0;
> 
> _// _
> 
> function F=lineaire(X, A2, B2)
> 
> F = A2*X+B2;
> 
> endfunction
> 
> _// _
> 
> function G=racine(X, A1, B1)
> 
> G = sqrt(A1*X) + B1;
> 
> endfunction
> 
> _// _
> 
> function F=target(X, A1, B1, A2, B2)
> 
> val_lin = lineaire(X,A2,B2);
> 
> val_rac = racine(X,A1,B1);
> 
> F = sqrt((val_lin - val_rac)^2); 
> 
> global count_use;
> 
> count_use = count_use +1;
> 
> endfunction
> 
> _// Cost function: _
> 
> function [F, G, IND]=cost(X, IND, A1, B1, A2, B2)
> 
> F = target(X);   
> 
> _//g = numderivative(target, x.',order = 4); _
> 
> G = numderivative(target, X.',1e-3, order = 4);  _// 1E-3 => see EE 221 
> "Numerical Computing" Scott Hudson_
> 
> _// Study of the influence of h on the number of target function calculation 
> & the fopt accuracy:_
> 
> _// (epsg = %eps here)_
> 
> _// h = 1.e-1 => number = 220 & fopt = 2.242026e-05_
> 
> _// h = 1.e-2 => number = 195 & fopt = 2.267564e-07_
> 
> _// h = 1.e-3 => number = 170 & fopt = 2.189495e-09 ++_
> 
> _// h = 1.e-4 => number = 190 & fopt = 1.941203e-11_
> 
> _// h = 1.e-5 => number = 215 & fopt = 2.131628e-13_
> 
> _// h = 1.e-6 => number = 235 & fopt = 0._
> 
> _// h = 1.e-7 => number = 255 & fopt = 7.105427e-15_
> 
> _// h = 1.e-8 => number = 275 & fopt = 0._
> 
> endfunction
> 
> _// *_
> 
> _// optimisation with optim_
> 
> initial_parameters = [10]
> 
> lower_bounds = [0];
> 
> upper_bounds = [1000];
> 
> nocf = 1000;  _// number max of call of f_
> 
> niter = 1000;_// number max of iterations_
> 
> a1 = 30;
> 
> b1 = 2.5;
> 
> a2 = 1;
> 
> b2 = 2;
> 
> epsg = 1e-5;_// gradient norm threshold (%eps by defaut) --> lead to err 
> = 1 !!!_
> 
> _//epsg = %eps; // lead to Err = 13_
> 
> epsf = 0;   _//threshold controlling decreasing of f (epsf = 0 by defaut)_
> 
> costf = list (cost, a1, b1, a2, b2);
> 
> [fopt, xopt, gopt, work, iters, evals, err] = 
> optim(costf,'b',lower_bounds,upper_bounds,initial_parameters,'qn','ar',nocf,niter,epsg,epsf);
> 
> printf("Optimized value : %g\n",xopt);
> 
> printf("min cost function value (should be as closed as possible to 0) ; 
> %e\n",fopt);
> 
> printf('Number of calculations = %d !!!\n',count_use);
> 
> _// Curves definition_
> 
> x = linspace(0,50,1000)';
> 
> plot_raci = racine(x,a1,b1);
> 
> plot_lin = lineaire(x,a2,b2);
> 
> scf(1);
> 
> drawlater();
> 
> xgrid(3);
> 
> f = gcf(); 
> 
> _//f  _
> 
> f.figure_size = [1000, 1000];
> 
> f.background = color(255,255,255);   
> 
> a = gca();   
> 
> _//a  _
> 
> a.font_size = 2; 
> 
> a.x_label.text = "X axis" ;  
> 
> a.x_location="bottom";   
> 
> a.x_label.font_angle=0;  
> 
> a.x_label.font_size = 4; 
> 
> a.y_label.text = "Y axis";
> 
> a.y_location="left";
> 
> a.y_label.font_angle=-90;
> 
> a.Y_label.font_size = 4;
> 
> a.title.text = "Title"; 
> 
> a.title.font_size = 5;
> 
> a.line_style = 1;
> 
> _// Curves plot_
> 
> plot(x,plot_lin);
> 
> e1 = gce(); 
> 
> p1 = e1.children;   
> 
> p1.thickness = 1;
> 
> p1.line_style = 1;
> 
> p1.foreground = 3;
> 
> plot(x,plot_raci);
> 
> e2 = gce(); 
> 
> p2 = e2.children;

Re: [Scilab-users] Creation of a library with macros located in various folders

2016-10-16 Thread Pierre Vuillemin

Hello Samuel,

Those are great news, I am really looking forward the release of Scilab 6!

In the mean time I've managed to make something that is working (similar 
to your script). It will be enough until the release.


Regards,

Pierre


Le 15/10/2016 à 17:31, Samuel Gougeon a écrit :

Hello Pierre,

Scilab 6.0 will propose a new function *tbx_make*(..) that will be 
able to do exactly what you want:

https://codereview.scilab.org/#/c/18071/

By the way, it will greatly simplify compilation of modules, and will 
no longer require many cooky-files .sce like buildmacros.sce 
buildoc.sce etc etc spread everywhere in the tree of files of a module.
On the forefront, tbx_make() aims to replace & merge most of functions 
of the "modules manager" module, that are rather some atomic internals 
not really welcome as public functions:

https://help.scilab.org/docs/6.0.0/en_US/section_d8452c14ec97df3c90ea90bb4f7d53b6.html

If you use Scilab on Linux, you can already test tbx_make() in the 
nightly built release (*).


If you are working with Scilab 5, you may use the attached script. Its 
how-to is in comments.


Regards
Samuel

(*) tbx_make() merged on 2016-10-02 in the master release is still 
unavailable in the today NB sticking on the 2016-09-22 sources for 
Windows.


Le 12/10/2016 22:00, Pierre Vuillemin a écrit :


Hi all,

I am trying to make a function similar to genlib but which goes 
recursively through folders to find .sci files, compile them and put 
them in a given target build folder.


The idea is that I would like to be able to organize my 'macros' 
folder while still being able to generate a library. In particular, I 
would like to have that kind of folder organization :


.../...




___
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] Creation of a library with macros located in various folders

2016-10-15 Thread Pierre Vuillemin

Well, after some trials and (mainly) errors,

it seems that when saving a function which name is given by the variable 
function_name,


save(function_name + ".bin", function_name)

does not work, while

 execstr("save("""function_name + ".bin""," +function_name+")")

does work.

The attached file contains a routine that goes recursively through 
folders in a given path to find the .sci files and create a library in a 
given build folder. It works as follows,


rgenlib(lib_name, src_path, target_path)

It seems to be 'working' but produces warnings due to:
- the way binary files are saved (see above), which will change in 
Scilab 6 if I am correct,
- the functions in the library being already loaded in Scilab for some 
reason.


If anyone has an insight concerning the second point, I am interested.

Best regards,

Pierre

Le 12/10/2016 à 22:00, Pierre Vuillemin a écrit :


Hi all,

I am trying to make a function similar to genlib but which goes 
recursively through folders to find .sci files, compile them and put 
them in a given target build folder.


The idea is that I would like to be able to organize my 'macros' 
folder while still being able to generate a library. In particular, I 
would like to have that kind of folder organization :


- build
 
 
- src
 - sub-folder1
 <.sci files>
 ...
 - sub-folder n
- sub sub folder 1
<.sci files>
 < .sci files>


At the moment, the function (build.sce in the attached file) goes 
through the folders contained in the initial 'src' folder, performs an 
'exec' on the .sci files that are found, and save the corresponding 
binary files in the target folder 'build' (at the same level as 
'src'). It also generates a 'names' file containing the names of the 
functions in the 'build' folder.


Finally, it creates a library with the binary files contained in the 
'build' folder.



Yet, when I try to use my functions, I get the following error:

  !--error 999
Overloaded load cannot occur in this context

So I guess that there is something wrong with the way I generate my 
library?


My binary files are generated as follows,

 function_name  = strsubst(fi,".sci","") // fi is the full 
name of the file
 names_to_write = [names_to_write;function_name] // used later 
to generate the file containing the names
 exec(file_path, -1)  // file_path is the absolute path to my 
function

 save(target_path + function_name + ".bin", function_name)

and the names file is generated as,

  names_file = target_path  + "names"
   [fd, err] = mopen(names_file,"a")
   mputl(names_to_write, fd)
   mclose(fd)


Best regards,

Pierre Vuillemin



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




rgenlib.sci
Description: application/scilab-sci
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] overloading concat "[ ]" operators

2016-07-01 Thread Pierre Vuillemin

Hi Philippe,

You can create another object, a matrix of bing int that stacks your 
bigint in a list, i.e.


x = tlist(["bigint","rep","signe"],[7654321;5678998;1234],1)
y = tlist(["bigint","rep","signe"],[3456789;5432112;9876],1)
X = tlist(["mbigint","entries"],list(x,y))

Then  you can overload the display for "mbigint" for instance with

function %mbigint_p(e)
str = ""
for i = 1:length(e.entries)
for j =length(e.entries(i).rep):-1:1
str =  sprintf("%s%d",str,e.entries(i).rep(j))
end
str = str +"\n"
end
printf(str)
endfunction

If you want to make matrix (not only vectors), then you need to add the 
size of the matrix as an attribute of "mbigint" and reshape the display 
accordingly.



Pierre.

Le 01.07.2016 10:41, philippe a écrit :

Hi,

I have created a simple data structure  to handle "big integers" . It 
is

 based on scilab tlist  and named "bigint" . I have overloaded basic
unary/binary operators for bigint (like +,*,-,/,^,==,<,>,... ) :



-->x=bigint('123456789987654321')
 x  =


 123456789987654321

-->y=bigint('987654321123456789')
 y  =


 987654321123456789

-->z=x-y
z =


-864197531135802468



but now I want to create matrix of bigint  so I need to create
functions like %bigint_c_bigint   and %bigint_f_bigint . I try using
"cell" It's not exactly what I was expecting : matrix entries  are
displayed as tlist  instead of bigint display (modified via %bigint_p )



-->T=cell()
 T  =


 []



-->T(1).entries=x
 T  =


 tlist(["bigint","rep","signe"],[7654321;5678998;1234],1)

-->T(2).entries=y
 T  =


!tlist(["bigint","rep","signe"],[7654321;5678998;1234],1)  !
!  !
!tlist(["bigint","rep","signe"],[3456789;5432112;9876],1)  !


-->T(3).entries=z
 T  =


!tlist(["bigint","rep","signe"],[7654321;5678998;1234],1)   !
!   !
!tlist(["bigint","rep","signe"],[3456789;5432112;9876],1)   !
!   !
!tlist(["bigint","rep","signe"],[5802468;9753113;8641],-1)  !



how could I get  a display like


-->T
T =


!  123456789987654321 !
! !
!  987654321123456789 !
! !
! -864197531135802468 !



actually I only get

-->T.entries
 ans  =


   ans(1)


 123456789987654321

   ans(2)


 987654321123456789

   ans(3)


 -864197531135802468



Philippe

___
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] Backslash operator with square singular matrix

2015-10-27 Thread Pierre Vuillemin
Well, I must have switched the warnings off at some point and I did not 
realise that it was persistent.


Thank you for pointing that out.


Now that I can see the warnings, this leads me to another question :

With dense matrices, rcond seems to be used to detect singularity when 
doing A\b while in the sparse case, rank deficiency is checked.


cond, rcond and rank works with dense matrices, condestsp works with 
sparse matrices but not with singular ones.


What would be a consistent (and efficient?) way of detecting matrix 
singularity? Through LU factorisation to get the rank of the matrix?




Le 27.10.2015 14:53, Stéphane Mottelet a écrit :

Hello,



Le 27/10/2015 13:27, Pierre Vuillemin a écrit :

A = [2 4;1 2];
disp(det(A))
b = [1;1];
x = A \ b;

-->A = [2 4;1 2];

-->disp(det(A))

0.

-->b = [1;1];

-->x = A \ b;
Attention :
La matrice est presque singulière ou mal conditionnée. rcond = 
0.D+00

Calcul de la solution des moindres carrés (voir lsq).

Isn't it a warning ?

S.

___
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] Colours in Scilab terminal

2015-10-22 Thread Pierre Vuillemin

Hello all,

I was wondering if it was possible to display coloured text in Scilab 
terminal with "mprintf" ?


It seems to be possible with printf in C : 
http://stackoverflow.com/questions/3219393/stdlib-and-colored-output-in-c


Best regards,

Pierre Vuillemin

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


Re: [Scilab-users] Get back the name of a function given as argument

2015-10-13 Thread Pierre Vuillemin

Hi Samuel,

Thank you for the answer. I have finally came up with this routine :

function funName = sopi_retrieveFunName(f)
varList = who_user(%f);
for i = 2:size(varList,1) // "f" is the local copy of the function 
and is the first one in the varList, it must be discarded

varName = varList(i);
execstr("var = "+varName);
if var == f then
funName = varName;
break;
end
end
endfunction

It retrieves the name of the function given as argument by comparing it 
to the user's variables. It (very) far from being elegant, but it seems 
to work.


Will there be a better way to achieve that with Scilab 6 ?

Pierre


Le 12.10.2015 21:02, Samuel Gougeon a écrit :

Hi Pierre,

Le 12/10/2015 16:46, Pierre Vuillemin a écrit :

Hi all,

I am building some optimisation tools, and in this context, I was 
wondering if it was possible to get back the name of a function given 
as argument of another function.


More specifically, consider the function 'fun' defined as

deff('[f,g] = fun(x)','f = x^2;g = 2*x');

and an optimisation routine "minimize" which first argument is a 
function.


Is there a way to get back the name of the function "fun" when calling 
"minimize(fun)" ?


I am afraid that, with 5.5.2,  you have to use something like
minimize("thefun") instead, with

function argout = minimize(fun,...)
execstr("fun="+fun);
   ...
endfunction

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


Re: [Scilab-users] Get back the name of a function given as argument

2015-10-13 Thread Pierre Vuillemin

My bad, I've just realised that

- this routine will actually give the name of the last copy of the 
function (in case of multiple imbricated function calls),


- besides, a simpler solution consists in using the name of the local 
copy of the function.


deff('y = fun(x)','y = x^2');
deff('y = f(x)','y = x');
deff('minimize(f)','disp(evstr(''f(2)''))');

minimize(f)   // displays 2
minimize(fun) // displays 4


Le 13.10.2015 08:44, Pierre Vuillemin a écrit :

Hi Samuel,

Thank you for the answer. I have finally came up with this routine :

function funName = sopi_retrieveFunName(f)
varList = who_user(%f);
for i = 2:size(varList,1) // "f" is the local copy of the function
and is the first one in the varList, it must be discarded
varName = varList(i);
execstr("var = "+varName);
if var == f then
funName = varName;
break;
end
end
endfunction

It retrieves the name of the function given as argument by comparing
it to the user's variables. It (very) far from being elegant, but it
seems to work.

Will there be a better way to achieve that with Scilab 6 ?

Pierre


Le 12.10.2015 21:02, Samuel Gougeon a écrit :

Hi Pierre,

Le 12/10/2015 16:46, Pierre Vuillemin a écrit :

Hi all,

I am building some optimisation tools, and in this context, I was 
wondering if it was possible to get back the name of a function given 
as argument of another function.


More specifically, consider the function 'fun' defined as

deff('[f,g] = fun(x)','f = x^2;g = 2*x');

and an optimisation routine "minimize" which first argument is a 
function.


Is there a way to get back the name of the function "fun" when 
calling "minimize(fun)" ?


I am afraid that, with 5.5.2,  you have to use something like
minimize("thefun") instead, with

function argout = minimize(fun,...)
execstr("fun="+fun);
   ...
endfunction

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


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


[Scilab-users] Get back the name of a function given as argument

2015-10-12 Thread Pierre Vuillemin

Hi all,

I am building some optimisation tools, and in this context, I was 
wondering if it was possible to get back the name of a function given as 
argument of another function.


More specifically, consider the function 'fun' defined as

deff('[f,g] = fun(x)','f = x^2;g = 2*x');

and an optimisation routine "minimize" which first argument is a 
function.


Is there a way to get back the name of the function "fun" when calling 
"minimize(fun)" ?


I would like to get back its name to wrap it inside another function 
which includes calls towards numerical derivatives, if needed.


Best regards,

Pierre Vuillemin










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


Re: [Scilab-users] Strange behaviour with for loops

2015-09-30 Thread Pierre Vuillemin

My bad, I was only focused on the list part of the help...

Thank you,

Pierre

Le 30.09.2015 09:50, Samuel Gougeon a écrit :

Hello Pierre,
Le 29/09/2015 16:20, Pierre Vuillemin a écrit :

Hello,
In the help, it is specified that the syntax 'for e = l ...' when l is 
a list is authorised. When l is replaced by a vector, the result 
appears to depend on whether its a column or row vector :

.../...
Is this behaviour intended?

.
Yes, and it is as well documented:
-->help for
"Description: .../... If expression is a matrix or a row vector,
variable takes as values the values of each column of the matrix."

Samuel Gougeon

___
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] Strange behaviour with for loops

2015-09-29 Thread Pierre Vuillemin

Hello,

In the help, it is specified that the syntax 'for e = l ...' when l is a 
list is authorised. When l is replaced by a vector, the result appears 
to depend on whether its a column or row vector :


With this code, the for loops runs 3 times and each time i is equal to 
another value of the vector idx


idx =[1 2 3];
for i = idx
disp("newIter")
disp(i)
end

When the vector idx is a column vector now, there is only one loop and i 
is equal to the vector idx


idx = [1 2 3]';
for i = idx
disp("newIter")
disp(i)
end

Is this behaviour intended?


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


Re: [Scilab-users] Booeleans : irrelevant results ?

2015-08-27 Thread Pierre Vuillemin
 

Dear Paul, 

The behaviour of test 2 may come from the order in which the operations
are performed : 

Note that (a  c  b) ~= (b  c  a), indeed : 

- a  c  b performs a  c which returns [] and then []  b which
returns [], 

- b  c  a performs b  c which returns %t and then %t  [] which
returns %t. 

You can obtain the desired behaviour by adding parenthesis 

b  (c  a) returns [] 

but it may be safer to use isempty() to check whether a variable is
empty or not. 

Best regards, 

Pierre 

Le 27.08.2015 12:29, Carrico, Paul a écrit : 

 Dear All, 
 
 I wondering what I'm doing wrong in the examples here bellow: 
 
 - Test 1 à M returns False that's ok for me 
 
 - Test 2 à should return False as well, shouldn't be ? 
 
 - Test 3 à another test using directly a Boolean instead of an empty form [] 
 
 - Test 4 à as expected, it returns F 
 
 Thanks for any highlight 
 
 Paul 
 
 ##
  
 
 mode(0) 
 
 _// test 1_ 
 
 M = []; 
 
 if M then 
 
 printf(M returns T\n); 
 
 else 
 
 printf(M returns F\n); 
 
 end 
 
 _// test 2_ 
 
 a=[]; 
 
 b=30; 
 
 c=200; 
 
 if (b  c  a) then 
 
 printf(val = 6\n); 
 
 else printf(val = []\n); _// should return [] ??_ 
 
 end 
 
 _// test 3_ 
 
 tmp = %f; 
 
 _//tmp = %t;_ 
 
 if (tmp) then 
 
 printf(tmp returns T\n); 
 
 else 
 
 printf(tmp returns F\n); 
 
 end 
 
 _// test 4_ 
 
 t1 = %t; 
 
 t2 = %t; 
 
 _//t3 = %t;_ 
 
 t3 = %f; 
 
 if (t1  t2  t3) then 
 
 printf((t1,t2,t3) returns T\n); 
 
 else 
 
 printf((t1,t2,t3) returns F\n); 
 
 end 
 
 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 [1]

 

Links:
--
[1] http://lists.scilab.org/mailman/listinfo/users
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] About the complex inverse tangent function

2014-08-15 Thread Pierre Vuillemin
Le vendredi 15 août 2014 à 11:28 +0200, Samuel Gougeon a écrit :
 Hello Pierre,
 
 Le 15/08/2014 10:52, Pierre Vuillemin a écrit :
  Le jeudi 14 août 2014 à 19:46 +0200, Samuel Gougeon a écrit :
  With Scilab 5.5.0 on Windows 7 x64:
  --z = 2*%i
z  =
   2.i
  --disp([atan(z),%i/2*log((%i+z)/(%i-z))])

   1.5707963 + 0.5493061i1.5707963 + 0.5493061i
  I am on a 64-bit linux environment (Debian Jessie, Scilab 5.5.0), the
  result would be OS-dependent?
 It is possible. Some packages or/and some single functions -- including 
 maths ones -- depend on the OS.
  The relation
 
  log(ab) = log(a) + log(b)
 
  only stands for the multi-valued logarithm function (or modulo pi). With
  the principal value of the log, defined as
 
  log(z) = ln(|z|) + i * arg(z)
 
  where -piarg(z)=pi,
 Is this interval conventionnaly standard for the principal value, rather 
 than -pi = arg(z)  pi ?

I have considered the same definitions as in 

(Section 4.1.2)
Handbook of Mathematical Functions: With Formulas, Graphs, and
Mathematical tables
Milton Abramowitz,Irene A. Stegun

or 

Branch Cuts for Complex Elementary Functions or Much Ado About Nothing's
Sign Bit 
W. Kahan 

The same domain for the principal value is used by Wolfram,
http://mathworld.wolfram.com/ComplexArgument.html

by Matlab, 
http://www.mathworks.fr/fr/help/symbolic/mupad_ref/arg.html

and seems to be used by Scilab as well
https://help.scilab.org/docs/5.5.0/en_US/atan.html

  this is not true as soon as -piarg(a)+arg(b)=
  pi. In particular, it is not true on the branch cut (- inf, 0].
  For instance,
 
  log(-1) = j pi
 
  log(-1)+log(-1) = 2j pi != log(1) = 0
 It is, modulo 2.pi : i.2.pi [2.pi] ~ i.0 = 0

The relation is also violated for any complex in the upper left half
plane, thus the modulo operation is not very well suited here.

Something less ambiguous seems to use the unwinding number :

The unwinding Number (R.M. Corless and D.J. Jeffrey) :
http://www.apmaths.uwo.ca/~djeffrey/Offprints/editors.pdf

which basically consists in adding 2Ki pi whenever required to make
standard relations work everywhere in the complex plane.

  This is merely a problem of convention in the definitions, but this
  leads to differences in the value of the atan on its branch cuts.
 Indeed. Both results that you get from atan and log on Linux are 
 correct, and equivalent.
 Results from win7 are equal and agree with the standard interval (-pi, pi].
 
 Samuel
 

I perfectly understand that each definition is equivalent up to 2K i
pi, yet from a numerical point of view, it seems to me that they cannot
be considered as equivalent. 

But the thing that really intrigues me is why the built-in function of
atan in Scilab does not lead to the same result (in the exact sense) as
the formulation in the commentary of the code 'watan.f'. 

I will try to determine what is really called by Scilab. The OS atan
would correspond.

Thank you for your answers. :)

Pierre
 

 ___
 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] About the complex inverse tangent function

2014-08-14 Thread Pierre Vuillemin
Hello,

my question concerns the practical implementation of the complex inverse
tangent function atan(z) in Scilab.

In the source code of Scilab, the file watan.f (in the elementary
functions) seems to compute this function as

atan(z) = i/2 log((i+z)/(i-z)),

where i^2=-1.

Yet, when comparing the result given by atan(z) and %i/2*log((%i+z)/(%
i-z)) in Scilab, they are different for every point on the imaginary
axis excepted in the unit circle. For instance,

z = 2*%i
disp([atan(z),%i/2*log((%i+z)/(%i-z))])

- 1.5707963 + 0.5493061i  - 1.5707963 + 0.5493061i

I would like to know where does the difference comes from and if
'watan.f' is really the file that computes atan.

The values obtained with the function atan(z) seem to coincide with
another definition of atan(z) :

atan(z) = 1/(2i) [log(1+iz)-log(1-iz)]

which is used by Mathematica and the function 'catan' in linux.

Pierre








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


Re: [Scilab-users] Interfacing fortran code with scilab

2014-02-05 Thread Pierre Vuillemin
I am quite used to work with Matlab, hence my code is fully vectorized,
however :
- some parts of my code cannot be vectorized (optimization loops, etc)
- some other parts are really not natural when written in a vectorized
way. Thus writting, reading, debugging and maintaining them is a pain.

But basically, I just would like to see the speed gain I can achieve
with a lower level language on some parts of my code.
Then depending on the performances of the forthcoming JIT compiler of
Scilab, I may consider to translate (or not) my code in fortran.

Pierre Vuillemin

Le mercredi 05 février 2014 à 12:38 +, Carrico, Paul a écrit :
 All
 
  before using fortan code, did you have a look to the vectorization in 
 order to avoid loops (that drastically decrease speed)  and to increase 
 speedup consequently ?
 
 Just an advice
 
 Paul
 
 -Message d'origine-
 De : users [mailto:users-boun...@lists.scilab.org] De la part de Pierre 
 Vuillemin
 Envoyé : mercredi 5 février 2014 09:56
 À : users@lists.scilab.org
 Objet : [Scilab-users] Interfacing fortran code with scilab
 
 Hello all,
 
 I am currently learning fortran in order to speed up some part o my code and 
 I would like to interface it with Scilab.
 
 To make some tests, I have used this fortran code :
 
 subroutine matmul(C,A,B,m,n,p)
 integer ::m,n,p,i,j,k
 real(kind=8),dimension(m,n),intent(in)::A
 real(kind=8),dimension(n,p),intent(in)::B
 real(kind=8),dimension(m,p),intent(out)::C
 real(kind=8):: temp
 C = 0
 do j =1,p
   do k=1,n
 temp = B(k,j)
 do i=1,m
 C(i,j)=C(i,j) + A(i,k)*temp
 end do
   end do
 end do
 end subroutine matmul
 
 which performs a matrix multiplication. Then I have used 'ilib_for_link'
 to create the link.
 It works but I have some questions : 
 
 - I did the same thing in Python with f2py and the code is seemingly faster 
 in python, I was wondering why ? (the precision is the same)
 
 - If I change the 'kind = 8' to 'kind = 4' in the fortran code, the function 
 returns a result which completely wrong.
 I expected it to be wrong, but not that much : for instance, with A = 10 and 
 B = 20, the call to the fortran function gives me '6.36D-314'  
 What is the reason? (My comprehension of how fortran types work with the kind 
 parameter is still limited, I know that kind=8 and kind=4 is not a very 
 portable expression though)
 
 - If I replace
 real(kind=8),dimension(m,p),intent(out)::C
 by
 real(kind=8),dimension(:,:),intent(out)::C
 I get a segfault in Scilab or it just closes. I was wondering why ? (I 
 thought it was something valid since gfortran still compiles)
 
 - Is it possible to keep the upper case in the name of fortran functions when 
 linked to scilab ? (At the beginning, my function was called 'matMul' and it 
 took me some time to figure out what the error message 'matMul is not an 
 entry point' meant)
 
 Best regards,
 
 Pierre Vuillemin
 
 ___
 users mailing list
 users@lists.scilab.org
 https://urldefense.proofpoint.com/v1/url?u=http://lists.scilab.org/mailman/listinfo/usersk=b2vlTQszY8VIpYRvaG%2By2A%3D%3D%0Ar=SzPQe21KEY%2BPdUhJge5w%2FdtbtLgIXw5YTsnbzx%2F7JYE%3D%0Am=ULVia0lWcxnisV%2BYAJ894mfD5PBI7UEZDeqeSqE9PQw%3D%0As=4501ea13ac011e234cb1dd1cdf1810c4388736b832cf43301a84c41f80b767f5
 
 
 
 Le présent mail et ses pièces jointes sont confidentiels et destinés à la 
 personne ou aux personnes visée(s) ci-dessus. Si vous avez reçu cet e-mail 
 par erreur, veuillez contacter immédiatement l'expéditeur et effacer le 
 message de votre système. Toute divulgation, copie ou distribution de cet 
 e-mail est strictement interdite.
 
 This email and any files transmitted with it are confidential and intended 
 solely for the use of the individual or entity to whom they are addressed. If 
 you have received this email in error, please contact the sender and delete 
 the email from your system. If you are not the named addressee you should not 
 disseminate, distribute or copy this email.
 


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


[Scilab-users] Name of function's input arguments

2013-05-29 Thread pierre vuillemin
Hello,

I would like to know if there exists a way to get the name of function's
inputs arguments, i.e., if I have the following function

function y = f(a,b)
..
endfunction

and that I call it like y = f(var1,var2), is it possible to know, inside my
function f, that the first input argument a is called var1 and that the
second one is called var2 ?

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