本文整理汇总了C#中ILArray类的典型用法代码示例。如果您正苦于以下问题:C# ILArray类的具体用法?C# ILArray怎么用?C# ILArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ILArray类属于命名空间,在下文中一共展示了ILArray类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: sphere
/// <summary>
/// Create surface data of a sphere
/// </summary>
/// <param name="n">number of facettes per angle</param>
/// <param name="X">[output] X coords</param>
/// <param name="Y">[output] Y coords</param>
/// <param name="Z">[output] Z coords</param>
public static void sphere(int n, out ILArray<double> X,out ILArray<double> Y,out ILArray<double> Z) {
ILArray<double> phi = repmat(linspace(-pi,pi,n).T,1,n);
ILArray<double> rho = repmat(linspace(0,pi,n),n,1);
Y = sin(phi) * sin(rho);
X = cos(phi) * sin(rho);
Z = cos(rho);
}
开发者ID:wdxa,项目名称:ILNumerics,代码行数:14,代码来源:ILSpecialData.cs
示例2: TestBucketSortArrayMatrixRow
private void TestBucketSortArrayMatrixRow() {
try {
ILArray<string> A = new ILArray<string>(3,4);
A[0,0] = "abc";
A[0,1] = "rtu";
A[0,2] = "sfkw";
A[0,3] = "lsdkfi";
A[1,0] = "iowejkc";
A[1,1] = "cjks";
A[1,2] = "wokys";
A[1,3] = "suem,";
A[2,0] = "fgj";
A[2,1] = "JKSF";
A[2,2] = "SEs";
A[2,3] = "SEFsr";
ILArray<double> ind;
ILArray<string> res = ILMath.sort(A,out ind,0,false);
if (!res.Equals(A[ind]))
throw new Exception("invalid indices/values detected");
ILArray<Int16> indI = ILMath.toint16(ILMath.counter(0.0,1.0,A.Dimensions.ToIntArray()));
res = ILMath.sort(A,ref indI, 0, true, new ILASCIIKeyMapper());
if (!res.Equals(A[indI]))
throw new Exception("invalid indices/values detected");
Success(" elapsed: " + m_stopwatch.ElapsedMilliseconds + " ms");
} catch (Exception e) {
Error(0, e.Message);
}
}
开发者ID:wdxa,项目名称:ILNumerics,代码行数:29,代码来源:TESTBucketSort.cs
示例3: WT_order
// Wake Code - Matlab
// Rasmus Christensen
// Control and Automation, Aalborg University
#endregion
internal static void WT_order(out ILArray<double> xOrder, out ILArray<double> yOrder, ILArray<double> xTurb, ILArray<double> yTurb)
{
#region "Used variables declaration"
ILArray<double> sorted;
ILArray<double> turbineOrder;
int sortCtr;
int i;
int j;
#endregion
sorted = sortrows(__[ xTurb.T, yTurb.T ], 1);
turbineOrder = zeros(length(sorted), 2);
sortCtr = 0;
for (i = 1; i <= length(sorted); i++)
{
for (j = i + 1; j <= length(sorted); j++)
{
if (sorted._(i, 1) == sorted._(j, 1))
{
sortCtr = sortCtr + 1;
}
}
turbineOrder[_(i, ':', i + sortCtr), _(':')] = sortrows(sorted[_(i, ':', i + sortCtr), _(':')], 2);
sortCtr = 0;
}
xOrder = turbineOrder[_(':'), _(1)];
yOrder = turbineOrder[_(':'), _(2)];
}
开发者ID:mohsenboojari,项目名称:offwind,代码行数:32,代码来源:WT_order.cs
示例4: sin
/// <summary>
/// Sinus of array elements
/// </summary>
/// <param name="A">input array</param>
/// <returns>Sinus of elements from input array</returns>
/// <remarks><para>If the input array is empty, an empty array will be returned.</para>
/// <para>The array returned will be a dense array.</para></remarks>
public static /*!HC:outCls*/ ILArray<double> /*!HC:HCfuncname*/ sin (/*!HC:inCls1*/ ILArray<double> A) {
if (A.IsEmpty)
return /*!HC:outCls*/ ILArray<double> .empty(A.Dimensions);
ILDimension inDim = A.Dimensions;
/*!HC:outArr*/ double [] retDblArr;
// build ILDimension
int newLength = inDim.NumberOfElements;
//retDblArr = new /*!HC:outArr*/ double [newLength];
retDblArr = ILMemoryPool.Pool.New</*!HC:outArr*/ double > (newLength);
int leadDimLen = inDim [0];
// physical -> pointer arithmetic
unsafe
{
fixed (/*!HC:outArr*/ double * pOutArr = retDblArr)
fixed (/*!HC:inArr1*/ double * pInArr = A.m_data) {
/*!HC:outArr*/ double * lastElement = pOutArr + retDblArr.Length;
/*!HC:outArr*/ double * tmpOut = pOutArr;
/*!HC:inArr1*/ double * tmpIn = pInArr;
while (tmpOut < lastElement) { // HC02
/*!HC:HCCompute02*/
*tmpOut++ = /*!HC:HCoperation*/ Math.Sin ( *tmpIn++ ) /*!HC:HCpostOp*/ ;
}
}
}
return new /*!HC:outCls*/ ILArray<double> ( retDblArr, inDim );
}
开发者ID:wdxa,项目名称:ILNumerics,代码行数:35,代码来源:sin.cs
示例5: ind2sub
/// <summary>
/// convert sequential index into subscript indices
/// </summary>
/// <param name="A">input array</param>
/// <param name="seqindex">sequential index</param>
/// <returns>subscript indices</returns>
/// <remarks><para>the length of the value returned will be the number of dimensions of A</para>
/// <para>if A is null or empty array, the return value will be of length 0</para>
/// </remarks>
/// <exception cref="System.IndexOutOfRangeException">if seqindex is < 0 or > numel(A)</exception>
public static int[] ind2sub(ILArray<complex> A, int seqindex) {
if (object.Equals(A,null) || A.IsEmpty)
return new int[0];
int [] ret = new int[A.Dimensions.NumberOfDimensions];
A.GetValueSeq(seqindex,ref ret);
return ret;
}
开发者ID:wdxa,项目名称:ILNumerics,代码行数:17,代码来源:ind2sub.cs
示例6: ROTATE_corrd
// Wake Code - Matlab
// Rasmus Christensen
// Control and Automation, Aalborg University
// N_turb = number of turbines.
// X_turb = x-position of turbine.
// Y_turb = y-position of turbine.
#endregion
internal static void ROTATE_corrd(out ILArray<double> out_x, out ILArray<double> out_y, ILArray<double> xTurb, ILArray<double> yTurb, double rotA)
{
#region "Used variables declaration"
ILArray<double> x_out;
ILArray<double> y_out;
int i;
#endregion
x_out = zeros(1, length(xTurb)); // Initialization x-coordinates
y_out = zeros(1, length(yTurb)); // Initialization y-coordinates
rotA = rotA * pi / 180; // Conversion to radians
for (i = 1; i <= length(xTurb); i++)
{
x_out._(i, '=', xTurb._(i) * cos(rotA) - xTurb._(i) * sin(rotA));
y_out._(i, '=', xTurb._(i) * sin(rotA) + yTurb._(i) * cos(rotA));
}
if (min_(x_out) < 0) // Moves the x-points if these are negative.
{
x_out = x_out + 500 + abs(min_(x_out));
}
if (min_(y_out) < 0) // Moves the y-points if these are negative.
{
y_out = y_out + 500 + abs(min_(y_out));
}
out_x = x_out;
out_y = y_out;
}
开发者ID:mohsenboojari,项目名称:offwind,代码行数:40,代码来源:ROTATE_corrd.cs
示例7: load
private static void load(string windMatFilePath, out ILArray<double> wind)
{
using (var WindMatFile = new ILMatFile(windMatFilePath))
{
wind = WindMatFile.GetArray<double>("wind");
}
}
开发者ID:mohsenboojari,项目名称:offwind,代码行数:7,代码来源:FarmControl.cs
示例8: trace
// DO NOT EDIT INSIDE THIS REGION !! CHANGES WILL BE LOST !!
/// <summary>
/// trace of matrix
/// </summary>
/// <param name="A">input matrix, size [m x n]</param>
/// <returns>scalar of same type as A with the sum of diagonal elements of A.</returns>
public static ILArray<complex> trace ( ILArray<complex> A) {
if (A.IsEmpty)
return ILArray<complex> .empty(A.Dimensions);
if (A.IsVector || A.IsScalar)
return A[0];
return sum(diag(A));
}
开发者ID:wdxa,项目名称:ILNumerics,代码行数:13,代码来源:trace.cs
示例9: forwBackwGenCheck
private static void forwBackwGenCheck(IILFFT fft, ILArray<fcomplex> A, ILArray<fcomplex> Result, int dim, float mult) {
ILArray<fcomplex> B = fft.FFTForward1D(A, dim);
if (ILMath.sumall(ILMath.abs(Result - B))/A.Dimensions.NumberOfElements / A.Dimensions[dim] > (double)ILMath.MachineParameterFloat.eps * mult)
throw new Exception("invalid value");
B = fft.FFTBackward1D(B, dim);
if (ILMath.sumall(ILMath.abs(A - B))/A.Dimensions.NumberOfElements / A.Dimensions[dim] > (double)ILMath.MachineParameterFloat.eps * mult)
throw new Exception("invalid value");}
开发者ID:wdxa,项目名称:ILNumerics,代码行数:7,代码来源:TEST_IILFFT_fcomplex_fcomplex.cs
示例10: Vector
// The special constructor is used to deserialize values.
public Vector(SerializationInfo info, StreamingContext context)
{
label = (double)info.GetValue("label", typeof(double));
valuesMDF = (ILArray<double>)info.GetValue("valuesMDF", typeof(ILArray<double>));
values = (ILArray<double>)info.GetValue("values", typeof(ILArray<double>));
id = (int)info.GetValue("id", typeof(int));
}
开发者ID:cechovsky,项目名称:DiplomaThesis,代码行数:8,代码来源:Vector.cs
示例11: cross
public static ILArray<double> cross(ILArray<double> A, ILArray<double> B, int dim)
{
// Input checking
if (!A.m_dimensions.IsSameShape(B.m_dimensions))
throw new ILDimensionMismatchException("Inputs must have the same size and shape.");
ILDimension outDims = A.m_dimensions;
double[] outArray = ILMemoryPool.Pool.New<double>(outDims.NumberOfElements);
if (dim >= outDims.NumberOfDimensions || dim < 0)
throw new Exception("Specified dim is out of bounds of the array!");
if (outDims[dim] != 3)
throw new Exception("Must have length 3 in the dimension where the cross product is taken.");
// Cross Product
int SID = outDims.SequentialIndexDistance(dim);
int crosses = outDims.NumberOfElements / 3;
int SID2 = 2 * SID;
for (int i = 0; i < crosses; i++)
{
outArray[i] = A.m_data[SID + i] * B.m_data[SID2 + i] - A.m_data[SID2 + i] * B.m_data[SID + i];
outArray[SID + i] = A.m_data[SID2 + i] * B.m_data[i] - A.m_data[i] * B.m_data[SID2 + i];
outArray[SID2 + i] = A.m_data[i] * B.m_data[SID + i] - A.m_data[SID + i] * B.m_data[i];
}
return new ILArray<double>(outArray, outDims);
}
开发者ID:wdxa,项目名称:ILNumerics,代码行数:29,代码来源:cross.cs
示例12: ClusterX
public ClusterX(SerializationInfo info, StreamingContext context)
: base(info, context)
{
child = (Node)info.GetValue("child", typeof(Node));
covarianceMatrixMDF = (ILArray<double>)info.GetValue("covarianceMatrixMDF", typeof(ILArray<double>));
label = (double)info.GetValue("label", typeof(double));
}
开发者ID:cechovsky,项目名称:DiplomaThesis,代码行数:7,代码来源:ClusterX.cs
示例13: Cluster
// The special constructor is used to deserialize values.
public Cluster(SerializationInfo info, StreamingContext context)
{
clusterPair = (ClusterPair)info.GetValue("clusterPair", typeof(ClusterPair));
items = (List<Vector>)info.GetValue("items", typeof(List<Vector>));
mean = (Vector)info.GetValue("mean", typeof(Vector));
meanMDF = (ILArray<double>)info.GetValue("meanMDF", typeof(ILArray<double>));
parent = (Node)info.GetValue("parent", typeof(Node));
}
开发者ID:cechovsky,项目名称:DiplomaThesis,代码行数:9,代码来源:Cluster.cs
示例14: imag
/// <summary>
/// imaginary part of complex array elements
/// </summary>
/// <param name="X">complex input array</param>
/// <returns>imaginary part of complex array</returns>
public static /*!HC:outCls1*/ ILArray<double> imag (/*!HC:inCls1*/ ILArray<complex> X) {
int nrX = X.m_dimensions.NumberOfElements;
/*!HC:outArr1*/ double [] retArr = new /*!HC:outArr1*/ double [nrX];
/*!HC:outCls1*/ ILArray<double> ret = new /*!HC:outCls1*/ ILArray<double> (retArr,X.m_dimensions);
for (int i= 0; i < nrX; i++) {
retArr[i] = X.GetValue(i).imag;
}
return ret;
}
开发者ID:wdxa,项目名称:ILNumerics,代码行数:14,代码来源:imag.cs
示例15: Test_Serialize
public void Test_Serialize() {
int errorCode = 0;
try {
double[] data = new double[1000 * 1000 * 10];
String filename = "ILDoubleArray_SerializeTest1.ils";
for (int i = 0; i < data.Length; i++)
data[i] = (double)i;
ILArray<double> A = new ILArray<double>(data, 1000,1000,10);
FileStream fs = new FileStream(filename, FileMode.Create);
Info("Serializing to file: (please wait...)");
A.Serialize(fs);
fs.Close();
FileInfo fi = new FileInfo(filename);
Info("Serialized to file: [1000 x 1000 x 10] => " + ((int)(fi.Length/1024)) + "kB");
// create reference storage from smaler range -> should Detach()
errorCode = 1;
filename = "ILDoubleArray_SerializeTest2.ils";
fs = new FileStream(filename, FileMode.Create);
ILArray<double> AR1 = (ILArray<double>)A[0,"0:600;30:400;0:end"];
AR1.Serialize(fs);
fs.Close();
fi = new FileInfo(filename);
Info("Serialized to file: [600 x 360 x 10] => " + ((int)(fi.Length / 1024)) + "kB");
// if reference storage saved effective memory - keep it as reference
errorCode = 2;
filename = "ILDoubleArray_SerializeTest3.ils";
fs = new FileStream(filename, FileMode.Create);
ILArray<double> AR2 = (ILArray<double>)A[0,"0:end,0:end;0:end,0:end;0:end"];
AR2.Serialize(fs);
fs.Close();
fi = new FileInfo(filename);
Info("Serialized to file: [2000 x 2000 x 20] => " + ((int)(fi.Length / 1024)) + "kB");
// test if small reference would NOT store full data array
errorCode = 4;
filename = "ILDoubleArray_SerializeTest4.ils";
fs = new FileStream(filename, FileMode.Create);
ILArray<double> AR3 = (ILArray<double>)A["3;3;1"];
AR3.Serialize(fs);
fs.Close();
fi = new FileInfo(filename);
Info("Serialized to file: [1 x 1] => " + ((int)(fi.Length / 1024)) + "kB");
if (fi.Length > 1024 * 2)
throw new Exception("Small reference storages should get detached before serializing!");
errorCode = 5;
Success("Test_serialize successfull");
} catch (SerializationException e) {
Error("Test_serialize failed on ErrorCode: "+ errorCode +"due: " + e.Message);
} catch (Exception e) {
Error("Test_serialize failed on ErrorCode: " + errorCode + "due: " + e.Message);
}
}
开发者ID:wdxa,项目名称:ILNumerics,代码行数:57,代码来源:TESTILNumericArray.cs
示例16: unique
/// <summary>Unique and sorted elements of a vector.</summary>
/// <param name="X">Elements from which to extract unique values (treated as a vector).</param>
/// <param name="whereResultInX">Indices (same size as retValue) such that x[whereResultInX] = retValue.</param>
/// <param name="whereXInResult">Indices (same size as x) such that retValue[whereXInResult] = x.</param>
/// <returns>Sorted row vector with size less than or equal to x where no 2 elements have the same value.</returns>
public static ILArray<double> unique(ILArray<double> X, out ILArray<double> whereResultInX, out ILArray<double> whereXInResult)
{
// 1. Handle empty and singleton cases
if (X.IsEmpty)
{
whereResultInX = new ILArray<double>();
whereXInResult = new ILArray<double>();
return new ILArray<double>();
}
if (X.IsScalar)
{
whereResultInX = new ILArray<double>(new double[] { 0 });
whereXInResult = new ILArray<double>(new double[] { 0 });
return X.C;
}
// 2. Sort
double[] x = (double[])X.m_data.Clone();
int[] oldXInd = ILMemoryPool.Pool.New<int>(x.Length);
for (int i = 0; i < x.Length; i++)
oldXInd[i] = i;
Array.Sort(x, oldXInd);
// 3. Declarations
int unqCount = 1;
for (int i = 1; i < x.Length; i++)
if (x[i - 1] != x[i])
unqCount++;
double[] unq = ILMemoryPool.Pool.New<double>(unqCount);
double[] wxnr = ILMemoryPool.Pool.New<double>(x.Length);
double[] wrnx = ILMemoryPool.Pool.New<double>(unqCount);
// 4. Unique
unq[0] = x[0];
wxnr[oldXInd[0]] = 0;
wrnx[0] = oldXInd[0];
for (int i = 1, j = 1; i < x.Length; i++)
{
if (x[i - 1] != x[i])
{
unq[j] = x[i];
wrnx[j] = oldXInd[i];
j++;
}
wxnr[oldXInd[i]] = j - 1;
}
whereResultInX = new ILArray<double>(wrnx);
whereXInResult = new ILArray<double>(wxnr);
return new ILArray<double>(unq);
}
开发者ID:wdxa,项目名称:ILNumerics,代码行数:61,代码来源:unique.cs
示例17: Calculate
//private void wakeCalculation(ILArray<double> Ct, int i, ILCell wind, out ILArray<double> v_nac)
public static void Calculate(ILArray<double> Ct, int i, ILMatFile wind, out ILArray<double> v_nac)
{
//% v_nac = WAKECALCULATION(Ct,i,wind)
//This function calculates the wake
//Currently it is a very very simplified wake calculation. It just serves as
//a placeholder for a correct wake calculation that will come later
ILArray<double> scaling = ILMath.linspace(0.5, 0.9, Ct.Length);
v_nac = scaling * wind.GetArray<double>("wind").GetValue(i - 1, 1);
}
开发者ID:mohsenboojari,项目名称:offwind,代码行数:11,代码来源:WakeCalculation.cs
示例18: real
/// <summary>
/// real part of complex array
/// </summary>
/// <param name="X">complex input array</param>
/// <returns>real part of complex array</returns>
public static /*!HC:outCls1*/ ILArray<double> real (/*!HC:inCls1*/ ILArray<complex> X) {
int nrX = X.m_dimensions.NumberOfElements;
/*!HC:outArr1*/ double [] retArr = new /*!HC:outArr1*/ double [nrX];
/*!HC:outCls1*/ ILArray<double> ret = new /*!HC:outCls1*/ ILArray<double> (retArr,X.m_dimensions);
ILIterator</*!HC:inArr1*/ complex > it = X.CreateIterator(ILIteratorPositions.ILEnd,0);
for (int i= 0; i < nrX; i++) {
retArr[i] = it.Increment().real;
}
return ret;
}
开发者ID:wdxa,项目名称:ILNumerics,代码行数:15,代码来源:real.cs
示例19: forwBackwGenCheck
private static void forwBackwGenCheck(IILFFT fft, ILArray<double> A, ILArray<complex> Result, int dim, double mult) {
ILArray<complex> B = fft.FFTForward1D(A, dim);
if (ILMath.sumall(ILMath.abs(Result - B))/A.Dimensions.NumberOfElements / A.Dimensions[dim] > ILMath.MachineParameterDouble.eps * mult)
throw new Exception("invalid value");
ILArray<double> ResultR = fft.FFTBackwSym1D(B,dim);
if (ILMath.sumall(ILMath.abs(ResultR - A))/A.Dimensions.NumberOfElements / A.Dimensions[dim] > ILMath.MachineParameterDouble.eps * mult)
throw new Exception("invalid value");
B = fft.FFTBackward1D(B, dim);
if (ILMath.sumall(ILMath.abs(ILMath.tocomplex(A) - B))/A.Dimensions.NumberOfElements / A.Dimensions[dim] > ILMath.MachineParameterDouble.eps * mult)
throw new Exception("invalid value");}
开发者ID:wdxa,项目名称:ILNumerics,代码行数:10,代码来源:TEST_IILFFT_double_complex.cs
示例20: prod
/// <summary>
/// multiply and fold array elements along first non singleton dimension
/// </summary>
/// <param name="inArray">N-dimensional double array</param>
/// <returns>array having the first non singleton dimension
/// reduced to the length 1 with the result of the products of
/// corresponding elements of inArray in that dimension.
/// The result will have the same number of dimensions as
/// inArray, but the first non singleton dimension having the
/// size 1.</returns>
public static ILArray<double> prod(ILArray<double> inArray) {
int[] newDims = inArray.Dimensions.ToIntArray();
int nsDim = 0;
while (nsDim < newDims.Length && newDims[nsDim] < 2)
nsDim++;
if (nsDim == newDims.Length)
// scalar -> return copy
return (ILArray<double>)inArray.Clone();
return prod(inArray, nsDim);
}
开发者ID:wdxa,项目名称:ILNumerics,代码行数:20,代码来源:prod.cs
注:本文中的ILArray类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论