private static ColumnVector ConvertListToReadOnlyVector(IList <double> parameters) { // If it already is a column vector, just make sure it is read-only // and store it. (This assumes it's not a problem to make it read-only, // but since it was internally generated we control that.) ColumnVector vParameters = parameters as ColumnVector; if ((vParameters != null) && (vParameters.IsReadOnly)) { vParameters.IsReadOnly = true; return(vParameters); } // If it's an array, just convert it to a read-only column vector // (This assumes the array won't be modified later, but since it was // internally generated we control that.) double[] aParameters = parameters as double[]; if (aParameters != null) { parameters = new ColumnVector(aParameters, 0, 1, aParameters.Length, true); } // If necessary, copy the parameters. double[] cParameters = new double[parameters.Count]; parameters.CopyTo(cParameters, 0); return(new ColumnVector(cParameters, 0, 1, cParameters.Length, true)); }