[Scilab-users] Help for . operator

classic Classic list List threaded Threaded
4 messages Options
Perrichon Perrichon
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] Help for . operator

Hello

 

I got instruction coming from Matlab, and strictly reported in Scilab, like for example :

 

    ee=k1*(2*g*(sjt.^2)).^(-1); // Calcul de la perte de charge singulière au niveau du vannage (en supposant que son coefficient multiplicateur est égal à 1)

 

It works, but I don’t understand le role of the « point » operator ‘.’

 

Without the ‘.’, it gives the same result

 

    ee=k1*(2*g*(sjt^2))^(-1); // Calcul de la perte de charge singulière au niveau du vannage (en supposant que son coefficient multiplicateur est égal à 1)

 

Any explanation.

 

Thank a lot for your response

 

All variables are simple flotting point in a sci routine

 

BR.

 

Pierre

 

 

 

 


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Dang Ngoc Chan, Christophe Dang Ngoc Chan, Christophe
Reply | Threaded
Open this post in threaded view
|

Re: {EXT} Help for . operator

Hello Pierre,

> De : Perrichon
> Envoyé : lundi 8 juin 2020 11:07
>
> I don't understand le role of the « point » operator '.'

The dot is used to have an element-wise operation.

The difference is when you work with matrices, e.g. the product * will make a matrix product

C = A*B -> C(i, j) = sum_k (A(i, k), B(k, j))

but .* will make the elementwise product

C = A.*B -> C(i, j) = A(i, j)*B(i, j)

See https://help.scilab.org/docs/6.1.0/en_US/dot.html

regards

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer


General
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
mottelet mottelet
Reply | Threaded
Open this post in threaded view
|

Re: {EXT} Help for . operator

Hello,

The problem is the actual tolerance of Scilab which allows to omit the
dot fot the power operator:

--> [1 2 3]^2
  ans  =

    1.   4.   9.

although Matlab does not allow it:

 >> [1 2 3]^2
Error using  ^
Incorrect dimensions for raising a matrix to a power. Check that the
matrix is square and the power is a scalar. To perform elementwise
matrix powers, use '.^'.

S.

Le 08/06/2020 à 11:21, Dang Ngoc Chan, Christophe a écrit :

> Hello Pierre,
>
>> De : Perrichon
>> Envoyé : lundi 8 juin 2020 11:07
>>
>> I don't understand le role of the « point » operator '.'
> The dot is used to have an element-wise operation.
>
> The difference is when you work with matrices, e.g. the product * will make a matrix product
>
> C = A*B -> C(i, j) = sum_k (A(i, k), B(k, j))
>
> but .* will make the elementwise product
>
> C = A.*B -> C(i, j) = A(i, j)*B(i, j)
>
> See https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/help.scilab.org/docs/6.1.0/en_US/dot.html
>
> regards
>
> --
> Christophe Dang Ngoc Chan
> Mechanical calculation engineer
>
>
> General
> This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
> _______________________________________________
> users mailing list
> [hidden email]
> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users

--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Perrichon Perrichon
Reply | Threaded
Open this post in threaded view
|

Re: {EXT} Help for . operator

Hello, and so much thanks for your response.

Stéphane enlightened me

If a and b are simple floating 1x1 then a^b is sufficient. a.^b does not need the "dot" operator

Nice day
Pierre

Before printing, think about ENVIRONMENTAL responsabity


-----Message d'origine-----
De : users <[hidden email]> De la part de Stéphane Mottelet
Envoyé : lundi 8 juin 2020 11:49
À : [hidden email]
Objet : Re: [Scilab-users] {EXT} Help for . operator

Hello,

The problem is the actual tolerance of Scilab which allows to omit the dot fot the power operator:

--> [1 2 3]^2
  ans  =

    1.   4.   9.

although Matlab does not allow it:

 >> [1 2 3]^2
Error using  ^
Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'.

S.

Le 08/06/2020 à 11:21, Dang Ngoc Chan, Christophe a écrit :

> Hello Pierre,
>
>> De : Perrichon
>> Envoyé : lundi 8 juin 2020 11:07
>>
>> I don't understand le role of the « point » operator '.'
> The dot is used to have an element-wise operation.
>
> The difference is when you work with matrices, e.g. the product * will
> make a matrix product
>
> C = A*B -> C(i, j) = sum_k (A(i, k), B(k, j))
>
> but .* will make the elementwise product
>
> C = A.*B -> C(i, j) = A(i, j)*B(i, j)
>
> See
> https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/help.
> scilab.org/docs/6.1.0/en_US/dot.html
>
> regards
>
> --
> Christophe Dang Ngoc Chan
> Mechanical calculation engineer
>
>
> General
> This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
> _______________________________________________
> users mailing list
> [hidden email]
> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists
> .scilab.org/mailman/listinfo/users

--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable Département Génie des Procédés Industriels Sorbonne Universités - Université de Technologie de Compiègne CS 60319, 60203 Compiègne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users