名前空間
変種
操作

std::slice

提供: cppreference.com
< cpp‎ | numeric‎ | valarray

 
 
ニューメリックスライブラリ
一般的な数学関数
浮動小数点環境
複素数
数値配列
擬似乱数生成
コンパイル時有理数演算 (C++11)
汎用の数値演算
Original:
Generic numeric operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
iota(C++11)
accumulate
inner_product
adjacent_difference
partial_sum
 
 
Defined in header <valarray>
class slice;
std::slicestd::valarrayスライスに似BLASのサブセットを識別するセレクタクラスです。開始インデックス、ストライド、およびサブセットの値の総数:タイプstd::sliceのオブジェクトは、次の3つの値を保持します。タイプstd::sliceのオブジェクトは、valarrayのoperator[]持つインデックスとして使用することができます.
Original:
std::slice is the selector class that identifies a subset of std::valarray similar to BLAS slice. An object of type std::slice holds three values: the starting index, the stride, and the total number of values in the subset. Objects of type std::slice can be used as indexes with valarray's operator[].
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] メンバ関数

スライスを作成します
Original:
constructs a slice
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数)
スライスの開始にアクセスします
Original:
accesses the start of the slice
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数)
スライスのサイズにアクセスします
Original:
accesses the size of the slice
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数)
スライスのストライドにアクセスします
Original:
accesses the stride of the slice
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数)

[編集]

トレース計算機能付きのベアボーンのvalarray担保Matrixクラス.
Original:
Barebones valarray-backed Matrix class with a トレース calculating function.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <iostream>
#include <valarray>
class Matrix {
    std::valarray<int> data;
    int dim;
 public:
    Matrix(int r, int c) : data(r*c), dim(c) {}
    int& operator()(int r, int c) {return data[r*dim + c];}
    int trace() const {
        return data[std::slice(0, dim, dim+1)].sum();
    }
};
int main()
{
    Matrix m(3,3);
    int n = 0;
    for(int r=0; r<3; ++r)
       for(int c=0; c<3; ++c)
           m(r, c) = ++n;
    std::cout << "Trace of the matrix (1,2,3) (4,5,6) (7,8,9) is " << m.trace() << '\n';
}

Output:

Trace of the matrix (1,2,3) (4,5,6) (7,8,9) is 15

[編集] も参照してください

valarrayの要素、スライス、またはマスクを設定/取得する
Original:
get/set valarray element, slice, or mask
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
valarrayの一般的なスライス:開始インデックス、長さのセットは、ストライドのセット
Original:
generalized slice of a valarray: starting index, set of lengths, set of strides
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(クラス) [edit]
スライスを適用した後のvalarrayのサブセットへのプロキシ
Original:
proxy to a subset of a valarray after applying a slice
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(クラステンプレート) [edit]