Class DoubleArrayStruct<TStruct>
- Namespace
- FinanceSharp
- Assembly
- FinanceSharp.dll
public class DoubleArrayStruct<TStruct> : DoubleArray, ICloneable, IDisposable, IEquatable<DoubleArray> where TStruct : unmanaged, DataStruct
Type Parameters
TStruct
- Inheritance
-
DoubleArrayStruct<TStruct>
- Implements
- Inherited Members
- Extension Methods
Constructors
DoubleArrayStruct()
public DoubleArrayStruct()
DoubleArrayStruct(params TStruct[])
public DoubleArrayStruct(params TStruct[] @struct)
Parameters
structTStruct[]The structure value that'll be wrapped.
Fields
values
protected TStruct[] values
Field Value
- TStruct[]
Properties
AsDoubleSpan
Wraps this DoubleArray with Span<T>.
public override Span<double> AsDoubleSpan { get; }
Property Value
Examples
fixed (double* _ = doublearray) {
doublearray.AsDoubleSpan.Fill(10d);
double[] ret = doublearray.AsDoubleSpan.ToArray();
}
Remarks
Best practice to use AsDoubleSpan safely is first using fixed operator on the array and then access AsDoubleSpan. See examples.
Count
The number of items in this array, each having n Properties.
public override int Count { get; protected set; }
Property Value
this[int]
Scalar overload.
public override double this[int property] { get; set; }
Parameters
propertyint
Property Value
this[int, int]
public override double this[int index, int property] { get; set; }
Parameters
Property Value
Properties
The count of properties for every
public override int Properties { get; protected set; }
Property Value
Methods
Clone()
Clones current DoubleArray.
public override DoubleArray Clone()
Returns
- DoubleArray
A new copy of this.
ComputeHashCode()
Additional hashcode for inherieted classes.
protected override int ComputeHashCode()
Returns
ForEach(ReferenceForFunctionHandler)
public override void ForEach(ReferenceForFunctionHandler function)
Parameters
functionReferenceForFunctionHandler
Get(int)
public virtual TStruct Get(int index)
Parameters
indexint
Returns
- TStruct
GetLinear(int)
Reads from this DoubleArray linearly regardless to shape.
public override double GetLinear(int offset)
Parameters
offsetintAbsolute offset
Returns
- double
The value at given
offset.
GetPinnableReference()
Provides a pinnable reference for fixing a DoubleArray.
public override ref double GetPinnableReference()
Returns
GetPinnableReference(int)
Provides a pinnable reference for fixing a DoubleArray at a specific index (of Count dimension).
public override ref double GetPinnableReference(int index)
Parameters
indexint
Returns
Examples
fixed (double* pointer = &arr.GetPinnableReference(0)) {
//use pointer to your needs
}
Get<TDestStruct>(int)
Casts item at index to TDestStruct.
public override TDestStruct Get<TDestStruct>(int index) where TDestStruct : unmanaged, DataStruct
Parameters
indexintThe index
Returns
- TDestStruct
Type Parameters
TDestStructThe destination structure.
IsEqualExactlyTo(DoubleArray)
A comparison method used when Equals(DoubleArray) is called from IEquatable<T> to compare same types of DoubleArray.
protected override bool? IsEqualExactlyTo(DoubleArray other)
Parameters
otherDoubleArrayAn DoubleArray to compare to this.
Returns
Reshape(int, int, bool)
Reshapes this DoubleArray to a shape of your choice, the shape must be
public override DoubleArray Reshape(int count, int properties, bool copy = true)
Parameters
countintThe count of items in this array.
propertiesintNumber of properties for every item in this array.
copyboolShould a copy be reshaped?
Returns
- DoubleArray
A DoubleArray2DManaged reshaped.
Exceptions
- ReshapeException
When unable to reshape to reshape: LinearLength != (
count*properties) then throws- ReshapeException
When copy is False. because TStruct is a representation of Properties dimension. call with copy: true
SetLinear(int, double)
Writes to this DoubleArray linearly regardless to shape.
public override void SetLinear(int offset, double value)