From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
|
Buffer
クラス(詳細は下記リンクを参照)で実現できます。double や int などの配列を効率的に複製できます。二次元配列から任意のチャンネルを取り出す関数のコードの例は、以下のとおりです。private double[] arraySubset(double[,] array, int row) {if
(array == null) //配列は空か?throw new
ArgumentNullException();
//配列の次元と、大きさを確認
if ( array.Rank < 2 || row < 0 || row > array.GetLength(0) )
throw new ArgumentException();
//列数を取得
int column = array.GetLength(1);
//新しい配列を確保
double[] data = new double[column];
//要素数を取得。double 型では要素あたり 8 バイト
int elementSize = System.Runtime.InteropServices.Marshal.SizeOf(array.GetType().GetElementType());
//元の配列からコピー
Buffer.BlockCopy(array,row * elementSize * column,data,0,elementSize*column);
return data;
}
|