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


sum

配列要素の合計

呼び出し手順

y = sum(x)
y = sum(x, outtype)
y = sum(x, orientation)
y = sum(x, orientation, outtype)

引数

x

ブール(full or sparse), エンコードされた整数, 実数または複素数(full or sparse),多項式, または有理数の配列.

orientation

以下のどちらかを指定します

  • 文字列で,指定可能な値は "*", "r", "c" または "m"

  • 正の整数値

outtype

文字列で,指定可能な値は "native" または "double".

y

スカラーまたは配列

説明

配列xの場合, y=sum(x)xの全要素の合計を スカラーyに返します.

y=sum(x,orientation) は, orientationで指定した次元方向の xの合計を yに返します.

  • orientation が 1 または "r" の場合:

    { y(\mathbf{1},j) = \sum_{\mathbf{i}} x(\mathbf{i},j)}

    または

    y(\mathbf{1},j,k,\ldots) = \sum_{\mathbf{i}} x(\mathbf{i},j,k,\ldots)

  • orientation が 2 または "c" の場合:

    y(i,\mathbf{1}) = \sum_{\mathbf{j}} x(i,\mathbf{j})

    または

    y(i,\mathbf{1},k,\ldots) = \sum_{j} x(i,\mathbf{j},k,\ldots)

  • orientation がnの場合:

    y(i_1,\ldots,i_{n-1},\mathbf{1},i_{n+1},\ldots) = \sum_{\mathbf{i_n}} x(i_1,\ldots,i_{n-1},\mathbf{i_n},i_{n+1},\ldots)

  • y=sum(x,"*")y=sum(x) と等価です.

  • y=sum(x,"m")y=sum(x,orientation) と等価です. ただし,orientation は, xの1より大きい最初の次元の添字です.

outtype引数は合算の動作を指定します:

  • float, 多項式, 有理数の配列の場合, 評価は常に浮動小数点計算で行われます. "double" または "native" オプションは等価です.

  • 整数の配列の場合,

    outtype="native" の場合, 評価は整数比較(モジュロ 2^b, ただし b は使用されるビット数) により行われます,

    outtype="double" の場合, 評価は浮動小数点計算で行われます.

    デフォルト値は outtype="native"です.

  • 論理値の配列の場合,

    outtype="native"の場合, 評価は論理値計算(+ は | で置換)により行われます,

    outtype="double"の場合, 評価は浮動小数点計算で行われます (%t は値1, %f は値0で置換されます).

    デフォルト値はouttype="double"です.

This function applies with identical rules to sparse matrices

A=[1,2;3,4];
sum(A)
sum(A,1)

I=uint8([2 95 103;254 9 0])
sum(I) //native evaluation
sum(I,"double")
sum(I,2,"double")

s=poly(0,"s");
P=[s,%i+s;s^2,1];
sum(P),
sum(P,2)

B=[%t %t %f %f];
sum(B) //evaluation in float
sum(B,"native") //similar to or(B)

参照

  • plus — 数値の加算。 テキストの連結(グループ化)
  • cumsum — 配列要素の累積和
  • prod — 配列要素の積
Report an issue
<< signm matrixoperations searchandsort >>

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:
Tue Mar 07 09:28:43 CET 2023