Example #1
0
        private float[] GetFloatInfo(string field)
        {
            ulong  lenULong;
            IntPtr result;
            int    output = XGBoostNative.XGDMatrixGetFloatInfo(_handle, field, out lenULong, out result);

            if (output == -1)
            {
                throw new DllFailException(XGBoostNative.XGBGetLastError());
            }

            int len = unchecked ((int)lenULong);

            float[] floatInfo = new float[len];
            for (int i = 0; i < len; i++)
            {
                byte[] floatBytes = new byte[4];
                floatBytes[0] = Marshal.ReadByte(result, 4 * i + 0);
                floatBytes[1] = Marshal.ReadByte(result, 4 * i + 1);
                floatBytes[2] = Marshal.ReadByte(result, 4 * i + 2);
                floatBytes[3] = Marshal.ReadByte(result, 4 * i + 3);
                float f = BitConverter.ToSingle(floatBytes, 0);
                floatInfo[i] = f;
            }
            return(floatInfo);
        }