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


union

ベクトルの和集合要素を展開

呼び出し手順

[v, ka, kb] = union(a, b)
[v, ka, kb] = union(a, b, orient)

引数

a, b
arrays of booleans, numbers, or strings. Sparse boolean or numerical matrices are accepted. The types of a and b can be distinct but compatible for concatenation.

orient orientation of the processing:
  • 1 or "r": the union is performed over rows.
  • 2 or "c": the union is performed over columns.

v
row vector, or matrix. v data type is the [a(:) ; b(:)]'s one.

ka
row vector of integers: Indices in a of v elements/rows/columns coming from a.

kb
row vector of integers: Indices in b of v remaining elements/rows/columns coming from b.

説明

union(a,b) は, [a(:);b(:)]のユニークなエントリ を保持するソート済みの行ベクトルを返します.

union(a,b,"r") または union(a,b,1)は, 辞書式に昇順にソートされた a および b のユニークな行の和集合により作成された行列を返します. この場合,行列aおよびb の列の数は同じである必要があります.

union(a,b,"c") または union(a,b,2)は, 辞書式に昇順にソートされた a および b のユニークな列の和集合により作成された行列を返します. この場合,行列aおよびb の行の数は同じである必要があります.

[v,ka,kb]=union(a,b) は, vがソートされたエントリ a(ka) および b(kb) 組みあわせとなるような 添字ベクトルka および kbも返します.

A = [6  7  6 ; 5  8  3 ];
B = [1  7  1  0  6 ];

union(A, B)
[u, ka, kb] = union(A, B)
--> union(A, B)
 ans  =
   0.   1.   3.   5.   6.   7.   8.

--> [u, ka, kb] = union(A, B)
 u  =
   0.   1.   3.   5.   6.   7.   8.
 ka  =
   6.   2.   1.   3.   4.
 kb  =
   4.   1.

A = ["a" "b" "a" "c" "c" "b"
     "b" "c" "a" "b" "c" "c" ];
B = ["b" "a" "c" "c" "b" "a"
     "a" "c" "b" "b" "b" "b" ];

[U, ka, kb] = union(A, B, "c")
--> [U, ka, kb] = union(A, B, "c")
 U  =
  "a"  "a"  "a"  "b"  "b"  "b"  "c"  "c"
  "a"  "b"  "c"  "a"  "b"  "c"  "b"  "c"

 ka  =
   3.   1.   2.   4.   5.

 kb  =
   2.   1.   5.

[F, T] = (%f, %t);
A = sparse([T T F T F T ; F F F F T T ; T F F F F T ]); full(A)
B = sparse([F F T T F F ; T T T T T T ; T F T T T F ]); full(B)

[U, ka, kb] = union(A, B, "c");
issparse(U)
full(U), ka, kb
--> A = sparse([T T F T F T ; F F F F T T ; T F F F F T ]); full(A)
 ans  =
  T T F T F T
  F F F F T T
  T F F F F T

--> B = sparse([F F T T F F ; T T T T T T ; T F T T T F ]); full(B)
 ans  =
  F F T T F F
  T T T T T T
  T F T T T F

--> [U, ka, kb] = union(A, B, "c");
--> issparse(U)
 ans  =
  T

--> full(U), ka, kb
 ans  =
  F F F T T T
  F T T F F T
  F F T F T T

 ka  =
   3.   5.   2.   1.   6.
 kb  =
   1.

参照

  • brackets — Concatenation. Recipients of an assignment. Results of a function
  • unique — ベクトルまたは行列のユニークなな要素を展開

履歴

バージョン記述
6.1.0 Extension to boolean matrices.
6.1.1 Extension to sparse boolean, sparse real, and sparse complex matrices.
Report an issue
<< setdiff setoperations unique >>

Copyright (c) 2022-2024 (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:
Mon Jun 17 17:54:17 CEST 2024