Table of Contents

Class DoubleArrayUnmanaged

Namespace
FinanceSharp
Assembly
FinanceSharp.dll

Provides a DoubleArray implementation for Address, a double*.

public class DoubleArrayUnmanaged : DoubleArray, ICloneable, IDisposable, IEquatable<DoubleArray>
Inheritance
DoubleArrayUnmanaged
Implements
Derived
Inherited Members
Extension Methods

Constructors

DoubleArrayUnmanaged()

public DoubleArrayUnmanaged()

DoubleArrayUnmanaged(double*, int, int, bool, Action)

public DoubleArrayUnmanaged(double* pointer, int count, int properties, bool zeroValues = false, Action disposer = null)

Parameters

pointer double*

A address to the wrapped memory block.

count int

The number of items in this array.

properties int

How many properties typed double are for every count

zeroValues bool

Should all the values in given pointer

disposer Action

the disposing action for deallocating given pointer

DoubleArrayUnmanaged(int, int, bool)

public DoubleArrayUnmanaged(int count, int properties, bool zeroValues = false)

Parameters

count int

The number of items in this array.

properties int

How many properties typed double are for every count

zeroValues bool

Fields

Address

public double* Address

Field Value

double*

disposer

protected Action disposer

Field Value

Action

Properties

AsDoubleSpan

Wraps this DoubleArray with Span<T>.

public override Span<double> AsDoubleSpan { get; }

Property Value

Span<double>

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

int

this[int]

Scalar overload.

public override double this[int property] { get; set; }

Parameters

property int

Property Value

double

this[int, int]

public override double this[int index, int property] { get; set; }

Parameters

index int
property int

Property Value

double

Properties

The count of properties for every

public override int Properties { get; protected set; }

Property Value

int

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

int

DiscardDisposer()

Nullifies disposer making this class no longer be responsible for the Address it contains.

public void DiscardDisposer()

ForEach(ReferenceForFunctionHandler)

public override void ForEach(ReferenceForFunctionHandler function)

Parameters

function ReferenceForFunctionHandler

GetLinear(int)

Reads from this DoubleArray linearly regardless to shape.

public override double GetLinear(int offset)

Parameters

offset int

Absolute offset

Returns

double

The value at given offset.

GetPinnableReference()

Provides a pinnable reference for fixing a DoubleArray.

public override ref double GetPinnableReference()

Returns

double

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

index int

Returns

double

Examples

fixed (double* pointer = &arr.GetPinnableReference(0)) {
    //use pointer to your needs
}

Get<TStruct>(int)

Casts item at index to TDestStruct.

public override TStruct Get<TStruct>(int index) where TStruct : unmanaged, DataStruct

Parameters

index int

The index

Returns

TStruct

Type Parameters

TStruct

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

other DoubleArray

An DoubleArray to compare to this.

Returns

bool?

Are this[int] equals to other. Null returned when test was not performed.

ReleaseUnmanagedResources()

protected override void ReleaseUnmanagedResources()

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

count int

The count of items in this array.

properties int

Number of properties for every item in this array.

copy bool

Should a copy be reshaped?

Returns

DoubleArray

Exceptions

ReshapeException

When unable to reshape to reshape: LinearLength != (count * properties) then throws

SetLinear(int, double)

Writes to this DoubleArray linearly regardless to shape.

public override void SetLinear(int offset, double value)

Parameters

offset int

Absolute offset to set value at.

value double

The value to write

Slice(int, int)

Slices (or wraps with a slice wrapper) the Count dimension.

public override DoubleArray Slice(int start, int stop)

Parameters

start int

Start of interval. The interval includes this value. The default start value is 0.

stop int

End of interval. The interval does not include this value, except in some cases where step is not an integer and floating point round-off affects the length of out.

Returns

DoubleArray

Returns a sliced array shaped (newCount, Properties)

Remarks

This slicing mechanism is similar to numpy's slice and will behave like the following:

thisArray[start:stop:1, :]

ToArray<TStruct>()

public TStruct[] ToArray<TStruct>()

Returns

TStruct[]

Type Parameters

TStruct