名前空間
変種
操作

「cpp/numeric/valarray/cshift」の版間の差分

提供: cppreference.com
< cpp‎ | numeric‎ | valarray
(Fix some translations)
 
1行: 1行:
{{tr_note}}
 
 
{{cpp/numeric/valarray/title|cshift}}
 
{{cpp/numeric/valarray/title|cshift}}
 
{{cpp/numeric/valarray/navbar}}
 
{{cpp/numeric/valarray/navbar}}
6行: 5行:
 
}}
 
}}
  
{{tr|位置{{tt|count}}要素により円にシフトされている要素と同じサイズの新規のvalarrayを返します。{{math|(i−count) mod s}}は、前の位置であると{{math|i}}が{{math|s}}であり、各要素の新しい位置が{{c|size()}}です.|Returns a new valarray of the same size with elements whose positions are shifted circularly by {{tt|count}} elements. The new position of each element is {{math|(i−count) mod s}} where {{math|i}} is the previous position and {{math|s}} is {{c|size()}}.}}
+
{{tt|count}} valarray {{math|(i−count) mod s}} {{math|i}} {{math|s}} {{c|size()}}
  
===パラメータ===
+
======
 
{{par begin}}
 
{{par begin}}
{{par | count |{{tr| によって要素をシフトする位置の数| number of positions to shift the elements by}}}}
+
{{par | count | }}
 
{{par end}}
 
{{par end}}
  
===値を返します===
+
======
{{tr|円シフトの要素を持つ結果のvalarray.|The resulting valarray with circularly shifted elements.}}
+
  
 
===ノート===
 
===ノート===
22行: 21行:
 
{{example|
 
{{example|
 
  | code=
 
  | code=
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 
  | output=
 
  | output=
 +
 +
 
}}
 
}}
  
===参照===
+
======
 
{{dsc begin}}
 
{{dsc begin}}
 
{{dsc inc | cpp/numeric/valarray/dsc shift}}
 
{{dsc inc | cpp/numeric/valarray/dsc shift}}
 
{{dsc end}}
 
{{dsc end}}
  
[[de:cpp/numeric/valarray/cshift]]
+
deenesfritptruzh
[[en:cpp/numeric/valarray/cshift]]
+
[[es:cpp/numeric/valarray/cshift]]
+
[[fr:cpp/numeric/valarray/cshift]]
+
[[it:cpp/numeric/valarray/cshift]]
+
[[pt:cpp/numeric/valarray/cshift]]
+
[[ru:cpp/numeric/valarray/cshift]]
+
[[zh:cpp/numeric/valarray/cshift]]
+

2018年7月1日 (日) 19:26時点における最新版

 
 
 
 
valarray<T> cshift( int count ) const;

位置を要素 count 個分循環シフトされた要素を持つ同じサイズの新しい valarray を返します。 それぞれの要素の新しい位置は (i−count) mod s です。 ただし i は以前の値で、 ssize() です。

目次

[編集] 引数

count - 要素をシフトする位置の数

[編集] 戻り値

循環シフトされた要素を持つ結果の valarray。

[編集] ノート

関数は std::valarray と異なる戻り値の型を使用して実装することができます。 この場合、その置換型は以下の性質を持ちます。

[編集]

#include <iostream>
#include <valarray>
 
 
int main() {
    std::valarray<int> v{1, 2, 3, 4, 5, 6, 7, 8};
 
    for (auto const& val : v) {
        std::cout << val << " ";
    }
    std::cout << "\n";
 
    std::valarray<int> v2 = v.cshift(2);
 
    for (auto const& val : v2) {
        std::cout << val << " ";
    }
    std::cout << "\n";
}

出力:

1 2 3 4 5 6 7 8 
3 4 5 6 7 8 1 2

[編集] 関連項目

valarray の要素をゼロ埋めシフトします
(パブリックメンバ関数) [edit]