Backends/SiaNet.Backend.TensorSharp/TensorFormatting.cs
/// <summary>
/// Gets the size of the format.
/// </summary>
/// <param name="minMax">The minimum maximum.</param>
/// <param name="intMode">if set to <c>true</c> [int mode].</param>
/// <returns>Tuple&lt;FormatType, System.Double, System.Int32&gt;.</returns>
Gets the size of the format.
Gets the size of the format .
private static Tuple<FormatType, double, int> GetFormatSize(Tuple<double, double> minMax, bool intMode)
        {
            var expMin = minMax.Item1 != 0 ?
                    (int)Math.Floor(Math.Log10(minMax.Item1)) + 1 :
                    1;
            var expMax = minMax.Item2 != 0 ?
                    (int)Math.Floor(Math.Log10(minMax.Item2)) + 1 :
                    1;
            if (intMode)
            {
                if (expMax > 9)
                    return Tuple.Create(FormatType.Scientific, 1.0, 11);
                else
                    return Tuple.Create(FormatType.Int, 1.0, expMax + 1);
            }
            else
            {
                if (expMax - expMin > 4)
                {
                    var sz = Math.Abs(expMax) > 99 || Math.Abs(expMin) > 99 ?
                        12 : 11;
                    return Tuple.Create(FormatType.Scientific, 1.0, sz);
                }
                else
                {
                    if (expMax > 5 || expMax < 0)
                    {
                        return Tuple.Create(FormatType.Float,
                            Math.Pow(10, expMax - 1), 7);
                    }
                    else
                    {
                        return Tuple.Create(FormatType.Float, 1.0,
                            expMax == 0 ? 7 : expMax + 6);
                    }
                }
            }
        }
private static Tuple < FormatType , double , int > GetFormatSize ( Tuple < double , double > minMax , bool intMode ) { var expMin = minMax . Item1 != 0 ? ( int ) Math . Floor ( Math . Log10 ( minMax . Item1 ) ) + 1 : 1 ; var expMax = minMax . Item2 != 0 ? ( int ) Math . Floor ( Math . Log10 ( minMax . Item2 ) ) + 1 : 1 ; if ( intMode ) { if ( expMax > 9 ) return Tuple . Create ( FormatType . Scientific , 1.0 , 11 ) ; else return Tuple . Create ( FormatType . Int , 1.0 , expMax + 1 ) ; } else { if ( expMax - expMin > 4 ) { var sz = Math . Abs ( expMax ) > 99 || Math . Abs ( expMin ) > 99 ? 12 : 11 ; return Tuple . Create ( FormatType . Scientific , 1.0 , sz ) ; } else { if ( expMax > 5 || expMax < 0 ) { return Tuple . Create ( FormatType . Float , Math . Pow ( 10 , expMax - 1 ) , 7 ) ; } else { return Tuple . Create ( FormatType . Float , 1.0 , expMax == 0 ? 7 : expMax + 6 ) ; } } } }
Gets the size of the format.
Gets the size of the format .
None
minMax
Tuple<double, double>
The minimum maximum.
The minimum maximum .
intMode
bool
if set to true
if set to true