Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.0.2 - 日本語

Change language to:
English - Français - Português - Русский

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Scilabヘルプ >> Elementary Functions > matrixoperations > sign

sign

signum function

Syntax

X = sign(A)

Arguments

А

matrix of encoded integers, decimal numbers, or complex numbers. A may be sparse.

X

matrix of the same size and data type as A.

Description

If X are integers or real numbers,

  • X(i) = -1 where A(i)<0
  • X(i) = 0 where A(i)==0
  • X(i) = 1 where A(i)>0
  • X(i)= %nan where A(i) is NaN.

If X is complex encoded: sign(A==0) = 0. Elsewhere, sign(A) = A./abs(A).

Examples

With decimal numbers:

m  = [ 1.25  -2.5  -%inf   2.75
       0.     1.    0.75   %inf
       %nan   0.   -1.5   -2.5 ]; m
sign(m)
--> m  =
   1.25  -2.5  -Inf    2.75
   0.     1.    0.75   Inf
   Nan    0.   -1.5   -2.5

--> sign(m)
 ans  =
   1.   -1.  -1.   1.
   0.    1.   1.   1.
   Nan   0.  -1.  -1.

With complex numbers:

i = %i;
c = [-1, -i, -3+4*i
      1,  i,  3+4*i
      3,  0,  3-4*i
     -4, 4*i,-4-3*i ];
c
sign(c)
--> c  =
  -1.  -i     -3. + 4.i
   1.   i      3. + 4.i
   3.   0.     3. - 4.i
  -4.   4.i   -4. - 3.i

--> sign(c)
 ans  =
  -1.  -i     -0.6 + 0.8i
   1.   i      0.6 + 0.8i
   1.   0.     0.6 - 0.8i
  -1.   i     -0.8 - 0.6i

With a sparse matrix:

sign(sprand(8,3,0.3,"normal"))

See also

  • abs — 絶対値, 大きさ
  • csgn — 複素数の実部のベクトル符号を返す
  • signm — 行列符号関数

History

バージョン記述
6.0 Extension to sparse matrices
Report an issue
<< prod matrixoperations signm >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Feb 14 15:02:07 CET 2019