예제 #1
0
 /// <summary>
 /// Matlab index.
 /// </summary>
 /// <param name="vec"></param>
 /// <param name="indices"></param>
 public VectorScatterRef(VectorBase <TMathNetVec, TConcreteVec> vec, IEnumerable <double> indices)
 {
     // Check
     NumericTool.CheckIndices(indices);
     this.vec     = vec;
     this.indices = indices.Select(i => (int)i - 1).ToArray();
 }
예제 #2
0
 internal MatrixSliceRef(Matrix mat, IEnumerable <double> rowIndices, IEnumerable <double> colIndices)
 {
     // Check.
     NumericTool.CheckIndices(rowIndices);
     NumericTool.CheckIndices(colIndices);
     this.mat        = mat;
     this.rowIndices = rowIndices.Select(d => (int)d - 1).ToArray();
     this.colIndices = colIndices.Select(d => (int)d - 1).ToArray();
 }
예제 #3
0
        /// <summary>
        /// Items inside <paramref name="indices"/> should all be integers.
        /// </summary>
        /// <param name="indices"></param>
        public static void CheckIndices(IEnumerable <double> indices)
        {
            var noneInts = indices.Where(d => !NumericTool.IsInteger(d)).ToArray();

            if (noneInts.Length > 0)
            {
                throw new ArgumentException($"Invalid index(ices) {string.Join("/", noneInts)}. Expect integer.");
            }
        }