Backends/SiaNet.Backend.TensorSharp/Cpu/CpuStorage.cs
/// <summary>
/// Gets the element as float.
/// </summary>
/// <param name="index">The index.</param>
/// <returns>System.Single.</returns>
/// <exception cref="NotSupportedException">Element type " + ElementType + " not supported</exception>
Gets the element as float.
Gets the element as float .
public override float GetElementAsFloat(long index)
        {
            unsafe
            {
                if(ElementType == DType.Float32) return ((float*)buffer.ToPointer())[index];
                else if (ElementType == DType.Float64) return (float)((double*)buffer.ToPointer())[index];
                else if (ElementType == DType.Int32) return (float)((int*)buffer.ToPointer())[index];
                else if (ElementType == DType.UInt8) return (float)((byte*)buffer.ToPointer())[index];
                else
                    throw new NotSupportedException("Element type " + ElementType + " not supported");
            }
        }
public override float GetElementAsFloat ( long index ) { unsafe { if ( ElementType == DType . Float32 ) return ( ( float * ) buffer . ToPointer ( ) ) [ index ] ; else if ( ElementType == DType . Float64 ) return ( float ) ( ( double * ) buffer . ToPointer ( ) ) [ index ] ; else if ( ElementType == DType . Int32 ) return ( float ) ( ( int * ) buffer . ToPointer ( ) ) [ index ] ; else if ( ElementType == DType . UInt8 ) return ( float ) ( ( byte * ) buffer . ToPointer ( ) ) [ index ] ; else throw new NotSupportedException ( " " + ElementType + " " ) ; } }
Gets the element as float.
Gets the element as float .
None
Element type " + ElementType + " not supported
Element type " + ElementType + " not supported
index
long
None