Re: [Scilab-users] overloading size for tlist

2017-07-23 Thread philippe
Le 23/07/2017 à 14:09, Samuel Gougeon a écrit :
> Hello Philippe,
> 
> In Scilab 5, size() is overloadable only for mlist(), not for tlist().
> In Scilab 6, it is overloadable for foth.
> So, to be compatible with both Scilab 5 and 6, you shall define your
> object as a mlist instead of tlist.

thank's Samuel, I was suspecting that the problem was coming from tlist.
I changed "mytype" to mlist instead of tlist and all works fine.

So now I don't understand what are tlist made for ? I was thinking that
mlist  was dedicated to "matrix of tlist"  but  we can use mlist  for
both matrix/non-matrix , it should be clarified ...

By,

Philippe

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


Re: [Scilab-users] overloading size for tlist

2017-07-23 Thread Samuel Gougeon

Hello Philippe,

In Scilab 5, size() is overloadable only for mlist(), not for tlist().
In Scilab 6, it is overloadable for foth.
So, to be compatible with both Scilab 5 and 6, you shall define your 
object as a mlist instead of tlist.


Best regards
Samuel

Le 23/07/2017 à 11:43, philippe a écrit :

Hi to all,

I've created a new type "mytype", represented by tlist, and another type
"matrixmytype", for matrix of "mytype" object, represented by mlist .
I've created the function %matrixmytype_size to overload the function
"size" for "matrixmytype" objects (it works fine) . For compatibility
reason I would like that size(x), where typeof(x)=='mytype', retrieve
the value [1,1], but actually size(x) return the size of the tlist for x
  an "mytype" .

  Let's take a minimal example :

//*
function x=mytype()
 x=tlist(['mytype' 'tab' 'pol' 'str'],..
 grand(2,3,'uin',1,3), ..  //x.tab
 poly(0,'x'), ..   //x.pol
 'scilab') //x.str
endfunction

function [p,n]=%mytype_size(x)
 [p,n]=size(x.tab)
endfunction
//**

then in scilab console :


//***
-->x=mytype()
  x  =


x(1)

!mytype  tab  pol  str  !

x(2)

 1.3.1.
 2.1.2.

x(3)

 x

x(4)

  scilab


-->[p,n]=%mytype_size(x)  // this is the expected result for size(x)
  n  =

 3.
  p  =

 2.

-->[p,n]=size(x)
   !--error 39
Nombre erroné d'arguments d'entrée.


-->size(x)
  ans  =

 4.

//


My goal is only to ensure overloading compatibility between mytype and
matrixmytype  like for "double"  size(x) returns [1,1] if x is a scalar
and not a matrix.

Thank's for reading !

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


[Scilab-users] overloading size for tlist

2017-07-23 Thread philippe
Hi to all,

I've created a new type "mytype", represented by tlist, and another type
"matrixmytype", for matrix of "mytype" object, represented by mlist .
I've created the function %matrixmytype_size to overload the function
"size" for "matrixmytype" objects (it works fine) . For compatibility
reason I would like that size(x), where typeof(x)=='mytype', retrieve
the value [1,1], but actually size(x) return the size of the tlist for x
 an "mytype" .

 Let's take a minimal example :

//*
function x=mytype()
x=tlist(['mytype' 'tab' 'pol' 'str'],..
grand(2,3,'uin',1,3), ..  //x.tab
poly(0,'x'), ..   //x.pol
'scilab') //x.str
endfunction

function [p,n]=%mytype_size(x)
[p,n]=size(x.tab)
endfunction
//**

then in scilab console :


//***
-->x=mytype()
 x  =


   x(1)

!mytype  tab  pol  str  !

   x(2)

1.3.1.
2.1.2.

   x(3)

x

   x(4)

 scilab


-->[p,n]=%mytype_size(x)  // this is the expected result for size(x)
 n  =

3.
 p  =

2.

-->[p,n]=size(x)
  !--error 39
Nombre erroné d'arguments d'entrée.


-->size(x)
 ans  =

4.

//


My goal is only to ensure overloading compatibility between mytype and
matrixmytype  like for "double"  size(x) returns [1,1] if x is a scalar
and not a matrix.

Thank's for reading !

Philippe

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