/// <summary>Converts the given byte array into a <see cref="UInt16"/></summary> /// <param name="Data">The byte array to convert</param> /// <returns>Converts the given byte array into a <see cref="UInt16"/></returns> public static UInt16 ToUInt16(Byte[] Data) { UInt16 Out; if (Data == null) { throw new ArgumentNullException(nameof(Data)); } if (Data.Length < sizeof(UInt16)) { throw new ArgumentException($"{nameof(Data)} is not of length 4 atleast"); } #if UNSAFE unsafe { fixed(Byte *s = Data) { UInt16 *d = &Out; *d = *(UInt16 *)s; } } #else Out = Data[0]; Out |= (UInt16)(Data[1] << 8); #endif return(Out); }
public static extern unsafe UInt32 AlazarDSPGetInfo(IntPtr dspHandle, UInt32 *dspModuleId, UInt16 *versionMajor, UInt16 *versionMinor, UInt32 *maxLength, UInt32 *reserved0, UInt32 *reserved1);
/// <summary> /// convert numerical ILArray to single precision floating point precision /// </summary> /// <param name="X">numeric input array</param> /// <returns><![CDATA[ILArray<float>]]> of same size as X having all elements converted to /// single precision floating point format.</returns> /// <remarks>All overloads of this function will return a solid physical copy /// of the input array X.</remarks> public static ILArray <float> single(ILArray <UInt16> X) { int nrX = X.m_dimensions.NumberOfElements; float [] retArr = new float [nrX]; ILArray <float> ret = new ILArray <float> (retArr, X.m_dimensions); unsafe { fixed(float *outArr = ret.m_data) fixed(UInt16 * inArr = X.m_data) { float * lastElementAfter = outArr + nrX; float * outArrP = outArr; UInt16 *inArrP = inArr; while (outArrP < lastElementAfter) { *outArrP++ = (float)*inArrP++; } } } return(ret); }
public unsafe static Int32 LoadImage(RECT *rect, UInt32 *p) { if ((Int32)rect->w == 0 || (Int32)rect->h == 0) { return(0); } PSX_LIBGPU.isVramDirty = true; UInt16 *numPtr1 = (UInt16 *)p; Int32 w = (Int32)rect->w; Int32 h = (Int32)rect->h; for (Int32 index1 = 0; index1 < h; ++index1) { for (Int32 index2 = 0; index2 < w; ++index2) { Int32 index3 = index1 * w + index2; Int32 index4 = ((Int32)rect->y + index1) * 1024 + ((Int32)rect->x + index2); if (PSX_LIBGPU.originalVram == null || PSX_LIBGPU.originalVram.Length == 0) { throw new AccessViolationException(); } else { originalVram[index4] = numPtr1[index3]; } } } return(0); }
public unsafe void Fill(UInt32 aStart, UInt32 aCount, UInt16 aData) { // TODO thow exception if aStart and aCount are not in bound. I've tried to do this but Bochs dies :-( UInt16 *xDest = (UInt16 *)(this.Base + aStart); MemoryOperations.Fill(xDest, aData, (int)aCount); }
/// <summary> /// sum all elements of array A /// </summary> /// <param name="A">n-dim array</param> /// <returns><para>scalar sum of all elements of A.</para> /// <para>If A is empty, an empty array will be returned.</para></returns> /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null.</exception> /// <seealso cref="ILNumerics.BuiltInFunctions.ILMath.sum(ILArray<double>)"/> public static ILArray<UInt16> sumall ( ILArray<UInt16> A) { if (object.Equals(A,null)) throw new ILArgumentException("sumall: argument must not be null!"); if (A.IsEmpty) { return ILArray<UInt16> .empty(0,0); } UInt16 retArr = 0 ; if (A.m_indexOffset == null) { unsafe { fixed ( UInt16 * inArrStart = A.m_data) { UInt16 * inArrWalk = inArrStart; UInt16 * inArrEnd = inArrStart + A.Dimensions.NumberOfElements; while (inArrWalk < inArrEnd) { retArr += *inArrWalk++; } } } } else { unsafe { fixed ( UInt16 * inArrStart = A.m_data) { for (int i = A.Dimensions.NumberOfElements; i -->0;) { retArr += *(inArrStart + A.getBaseIndex(i)); } } } } return new ILArray<UInt16> (new UInt16 [1]{retArr},1,1); }
unsafe public void Rec_Inventory_Data() { UInt32 error = 0; //error UInt16 *mem_data = stackalloc UInt16[100]; UInt16 data_len = 0; string str_epc; //MessageBox.Show("Rec_Inventory_Data"); while (start_scan_flag == true) { error = AsReaderOutputData(mem_data, &data_len); if (data_len > 0) { str_epc = Data16_to_str_epc(mem_data, data_len); Form1.myform1.textBox3.Invoke(new MethodInvoker(delegate { Form1.myform1.textBox3.Text += str_epc; })); Form1.myform1.textBox3.Invoke(new MethodInvoker(delegate { Form1.myform1.textBox3.Text += "\r\n"; })); Form1.myform1.textBox3.Invoke(new MethodInvoker(delegate { Form1.myform1.textBox3.Focus(); })); //Form1.myform1.textBox3.Invoke(new MethodInvoker(delegate { Form1.myform1.textBox3.Focus(); })); Form1.myform1.textBox3.Invoke(new MethodInvoker(delegate { Form1.myform1.textBox3.Select(Form1.myform1.textBox3.TextLength, 0); })); Form1.myform1.textBox3.Invoke(new MethodInvoker(delegate { Form1.myform1.textBox3.ScrollToCaret(); })); Thread.Sleep(100); data_len = 0; } } }
/// <summary> /// 从元数据转换为第三方客户数据 /// </summary> /// <param name="instance">目标对象</param> /// <param name="result">分析结果</param> /// <param name="data">元数据</param> /// <param name="offset">元数据所在的便宜量</param> /// <param name="length">元数据长度</param> public override void Process(object instance, GetObjectAnalyseResult result, byte[] data, int offset, int length = 0) { if (length == 4) { result.SetValue(instance, new UInt16[0]); return; } UInt16[] array; unsafe { fixed(byte *pByte = &data[offset]) { int arrLength = *(int *)pByte; array = new UInt16[arrLength]; if (arrLength > 10) { fixed(UInt16 *point = array) { Buffer.MemoryCopy((void *)new IntPtr(pByte + 4), (void *)new IntPtr((byte *)point), (uint)(Size.UInt16 * arrLength), (uint)(Size.UInt16 * arrLength)); //Native.Win32API.memcpy(new IntPtr((byte*)point), new IntPtr(pByte + 4), (uint)(Size.UInt16 * arrLength)); } } else { UInt16 *point = (UInt16 *)(pByte + 4); for (int i = 0; i < arrLength; i++) { array[i] = *(point++); } } } } result.SetValue(instance, array); }
/// <summary> /// minimum of all elements of array A /// </summary> /// <param name="A">n-dim array</param> /// <returns><para>scalar minimum of all elements of A.</para> /// <para>If A is empty, an empty array will be returned.</para></returns> /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null.</exception> /// <seealso cref="ILNumerics.BuiltInFunctions.ILMath.min(ILArray<double>)"/> public static ILArray <UInt16> minall(ILArray <UInt16> A) { if (object.Equals(A, null)) { throw new ILArgumentException("minall: argument must not be null!"); } if (A.IsEmpty) { return(ILArray <UInt16> .empty(A.Dimensions)); } UInt16 retArr = UInt16.MaxValue; unsafe { fixed(UInt16 *inArrStart = A.m_data) { UInt16 *inArrWalk = inArrStart; UInt16 *inArrEnd = inArrStart + A.Dimensions.NumberOfElements; while (inArrWalk < inArrEnd) { if (retArr > *inArrWalk) { retArr = *inArrWalk; } inArrWalk++; } } } return(new ILArray <UInt16> (new UInt16 [1] { retArr }, 1, 1)); }
public static string GetProfileString([NotNull] string sFilePath, [NotNull] string sSection, [NotNull] string sKey, [NotNull] string sDefaultValue) { if (sFilePath == null) { throw new ArgumentNullException("sFilePath"); } if (sSection == null) { throw new ArgumentNullException("sSection"); } if (sKey == null) { throw new ArgumentNullException("sKey"); } if (sDefaultValue == null) { throw new ArgumentNullException("sDefaultValue"); } UInt16 *buffer = stackalloc UInt16[StringLen]; GetPrivateProfileStringW(sSection, sKey, sDefaultValue, buffer, StringLen, sFilePath); buffer[StringLen - 1] = 0; return(new string((sbyte *)buffer)); }
} // writes register of hackrf chip public unsafe UInt16 ReadReg(HackrfChip chip, UInt16 register) { libhackrf.hackrf_error error = libhackrf.hackrf_error.HACKRF_ERROR_OTHER; UInt16 *valuePtr = (UInt16 *)Marshal.AllocHGlobal(2); switch (chip) { case HackrfChip.max2837: error = libhackrf.hackrf_max2837_read(device, (byte)register, valuePtr); break; case HackrfChip.si5351c: error = libhackrf.hackrf_si5351c_read(device, register, valuePtr); break; case HackrfChip.rffc5071: error = libhackrf.hackrf_rffc5071_read(device, (byte)register, valuePtr); break; } UInt16 ret = *valuePtr; Marshal.FreeHGlobal((IntPtr)valuePtr); if (error != libhackrf.hackrf_error.HACKRF_SUCCESS) { throw new Exception(error.ToString()); } return(ret); } // reads register of hackrf chip
public String[] GetProcedures() { unsafe { IntPtr codeBase = this._module.codeBase; IMAGE_DATA_DIRECTORY directory = this._module.headers.OptionalHeader.DataDirectory[0]; if (directory.Size == 0) { return new String[] { } } ; IMAGE_EXPORT_DIRECTORY exports = PointerHelpers.ToStruct <IMAGE_EXPORT_DIRECTORY>(codeBase, directory.VirtualAddress); UInt32 *nameRef = (UInt32 *)new IntPtr(codeBase.ToInt32() + exports.AddressOfNames); UInt16 *ordinal = (UInt16 *)new IntPtr(codeBase.ToInt32() + exports.AddressOfNameOrdinals); String[] result = new String[exports.NumberOfNames]; for (UInt32 i = 0; i < exports.NumberOfNames; i++, nameRef++, ordinal++) { IntPtr str = new IntPtr(codeBase.ToInt32() + (Int32)(*nameRef)); result[i] = Marshal.PtrToStringAnsi(str); } return(result); } }
/// <summary> /// Used to check/adjust data before we begin to interpret it /// </summary> private unsafe void FixupRawMftdata(byte *buffer, UInt64 len) { FileRecordHeader *ntfsFileRecordHeader = (FileRecordHeader *)buffer; if (ntfsFileRecordHeader->RecordHeader.Type != RecordType.File) { return; } UInt16 *wordBuffer = (UInt16 *)buffer; UInt16 *UpdateSequenceArray = (UInt16 *)(buffer + ntfsFileRecordHeader->RecordHeader.UsaOffset); UInt32 increment = (UInt32)_diskInfo.BytesPerSector / sizeof(UInt16); UInt32 Index = increment - 1; for (int i = 1; i < ntfsFileRecordHeader->RecordHeader.UsaCount; i++) { /* Check if we are inside the buffer. */ if (Index * sizeof(UInt16) >= len) { throw new Exception("USA data indicates that data is missing, the MFT may be corrupt."); } // Check if the last 2 bytes of the sector contain the Update Sequence Number. if (wordBuffer[Index] != UpdateSequenceArray[0]) { throw new Exception("USA fixup word is not equal to the Update Sequence Number, the MFT may be corrupt."); } /* Replace the last 2 bytes in the sector with the value from the Usa array. */ wordBuffer[Index] = UpdateSequenceArray[i]; Index = Index + increment; } }
/// <summary> /// This method will return the subsystem CUI/GUI value. The apphost file should be a windows PE file. /// </summary> /// <param name="accessor">The memory accessor which has the apphost file opened.</param> internal static unsafe UInt16 GetWindowsGraphicalUserInterfaceBit(MemoryMappedViewAccessor accessor) { byte *pointer = null; try { accessor.SafeMemoryMappedViewHandle.AcquirePointer(ref pointer); byte *bytes = pointer + accessor.PointerOffset; // https://en.wikipedia.org/wiki/Portable_Executable UInt32 peHeaderOffset = ((UInt32 *)(bytes + PEHeaderPointerOffset))[0]; if (accessor.Capacity < peHeaderOffset + SubsystemOffset + sizeof(UInt16)) { throw new AppHostNotPEFileException(); } UInt16 *subsystem = ((UInt16 *)(bytes + peHeaderOffset + SubsystemOffset)); return(subsystem[0]); } finally { if (pointer != null) { accessor.SafeMemoryMappedViewHandle.ReleasePointer(); } } }
public bool InternalProcess(ushort factor, uint size, byte[] inputbuffer, byte[] outputbuffer, int startIndex, uint length) { try { unsafe { fixed(byte *pInputBuffer = inputbuffer, pOutputBuffer = outputbuffer) { UInt16 *pInput = (UInt16 *)pInputBuffer; UInt16 *pOutput = (UInt16 *)(pOutputBuffer + startIndex); for (int i = 0; i < inputbuffer.Length / 2; ++i) { *pOutput = Add(*pOutput, Multiply(*pInput, factor)); ++pInput; ++pOutput; } } } return(true); } #if Debug catch (Exception ex) { Debug.WriteLine(ex); #else catch (Exception) { #endif return(false); } }
/// <summary> /// convert numerical ILArray to single precision floating point precision /// </summary> /// <param name="X">numeric input array</param> /// <returns><![CDATA[ILArray<float>]]> of same size as X having all elements converted to /// single precision floating point format.</returns> /// <remarks>All overloads of this function will return a solid physical copy /// of the input array X.</remarks> public static ILArray <float> single(ILArray <UInt16> X) { int nrX = X.m_dimensions.NumberOfElements; float [] retArr = new float [nrX]; ILArray <float> ret = new ILArray <float> (retArr, X.m_dimensions); if (X.IsReference) { for (int i = 0; i < nrX; i++) { retArr[i] = (float)X.GetValue(i); } } else { unsafe { fixed(float *outArr = ret.m_data) fixed(UInt16 * inArr = X.m_data) { float * lastElementAfter = outArr + nrX; float * outArrP = outArr; UInt16 *inArrP = inArr; while (outArrP < lastElementAfter) { *outArrP++ = (float)*inArrP++; } } } } return(ret); }
public static unsafe bool GetSourceInformation(UIntPtr sourceHandle, UIntPtr *storageHandle, UIntPtr *eventType, UInt16 *count, char *bufferName, UInt16 bufferSize) { UIntPtr tmpStorageHandle = 0; UIntPtr tmpEventType = 0; UInt16 tmpCount = 0; String name = ""; bool success = KernelControllerObject.GetSourceInformation(sourceHandle, ref tmpStorageHandle, ref tmpEventType, ref tmpCount, ref name); if (success) { *storageHandle = tmpStorageHandle; *eventType = tmpEventType; *count = tmpCount; String.LimitedFormatTo(name, new ArgIterator(), bufferName, bufferSize); } return(success); }
public static string TryLoadStringResource([NotNull] string sDllFilename, uint nResourceId) { if (sDllFilename == null) { throw new ArgumentNullException("sDllFilename"); } // DLL void *hModule = Kernel32Dll.LoadLibraryW(Path.GetFullPath(Environment.ExpandEnvironmentVariables(sDllFilename))); if (hModule == null) { return(null); } // Resource UInt16 *buffer = stackalloc UInt16[StringLen]; if (LoadStringW(hModule, nResourceId, buffer, StringLen) == 0) { return(null); } buffer[StringLen - 1] = 0; // Ensure it's Null-terminated return(new string((char *)buffer)); }
public unsafe UInt32 Hash(Byte[] dataToHash) { Int32 dataLength = dataToHash.Length; if (dataLength == 0) { return(0); } UInt32 hash = (UInt32)dataLength; Int32 remainingBytes = dataLength & 3; // mod 4 Int32 numberOfLoops = dataLength >> 2; // div 4 fixed(byte *firstByte = &(dataToHash[0])) { /* Main loop */ UInt16 *data = (UInt16 *)firstByte; for (; numberOfLoops > 0; numberOfLoops--) { hash += *data; UInt32 tmp = (UInt32)(*(data + 1) << 11) ^ hash; hash = (hash << 16) ^ tmp; data += 2; hash += hash >> 11; } switch (remainingBytes) { case 3: hash += *data; hash ^= hash << 16; hash ^= ((UInt32)(*(((Byte *)(data)) + 2))) << 18; hash += hash >> 11; break; case 2: hash += *data; hash ^= hash << 11; hash += hash >> 17; break; case 1: hash += *((Byte *)data); hash ^= hash << 10; hash += hash >> 1; break; default: break; } } /* Force "avalanching" of final 127 bits */ hash ^= hash << 3; hash += hash >> 5; hash ^= hash << 4; hash += hash >> 17; hash ^= hash << 25; hash += hash >> 6; return(hash); }
// http://landman-code.blogspot.ru/2009/02/c-superfasthash-and-murmurhash2.html public static unsafe ulong SuperFastHashUnsafe(byte[] dataToHash, long dataLength) { if (dataLength == 0) { return(0); } ulong hash = (ulong)dataLength; long remainingBytes = dataLength & 3; // mod 4 long numberOfLoops = dataLength >> 2; // div 4 fixed(byte *firstByte = &(dataToHash[0])) { /* Main loop */ UInt16 *data = (UInt16 *)firstByte; for (; numberOfLoops > 0; numberOfLoops--) { hash += *data; ulong tmp = (ulong)(*(data + 1) << 11) ^ hash; hash = (hash << 16) ^ tmp; data += 2; hash += hash >> 11; } switch (remainingBytes) { case 3: hash += *data; hash ^= hash << 16; hash ^= ((ulong)(*(((byte *)(data)) + 2))) << 18; hash += hash >> 11; break; case 2: hash += *data; hash ^= hash << 11; hash += hash >> 17; break; case 1: hash += *((byte *)data); hash ^= hash << 10; hash += hash >> 1; break; default: break; } } /* Force "avalanching" of final 127 bits */ hash ^= hash << 3; hash += hash >> 5; hash ^= hash << 4; hash += hash >> 17; hash ^= hash << 25; hash += hash >> 6; return(hash); }
private unsafe UInt16 FunctionF(UInt16 block) { UInt16 *p16 = █ var p8 = (byte *)p16; return((UInt16)((((UInt16)SBox1[p8[0] >> 4] + (UInt16)SBox2[p8[0] & 0xF]) ^ (UInt16)SBox3[p8[1] >> 4]) + (UInt16)SBox4[p8[1] & 0xF])); }
public void Read(UInt16 *p, Int32 min, Int32 max) { var token = _GetNumber(false); var value = UInt16.Parse(token); Runtime.RTCheckRange(value, min, max); *p = value; }
void RSCapture() { //----------------------RS--------------------- /* Make sure PXCMSenseManager Instance is Initialized */ if (psm == null) { LogText.text = "PXCMSM Failed"; return; } /* Wait until any frame data is available true(aligned) false(unaligned) */ if (psm.AcquireFrame(true) != pxcmStatus.PXCM_STATUS_NO_ERROR) { LogText.text = "Waiting..."; return; } /* Retrieve a sample from the camera */ PXCMCapture.Sample sample = psm.QuerySample(); if (sample != null) { LogText.text = "Capturing..."; } //-----UVMap-----// PXCMImage.ImageData imageData = new PXCMImage.ImageData(); sample.depth.AcquireAccess(PXCMImage.Access.ACCESS_READ_WRITE, PXCMImage.PixelFormat.PIXEL_FORMAT_DEPTH, PXCMImage.Option.OPTION_ANY, out imageData); bool found = false; unsafe { UInt16 *ptr = (UInt16 *)imageData.planes[0].ToPointer(); ulong length = (ulong)(sample.depth.info.width * sample.depth.info.height); for (ulong i = 0; ((i < length) && !found); i++, ptr++) { found = (*ptr > 0) && (*ptr < minimumDistanceMm); } a = ptr[120 * sample.depth.info.width + 320]; b = ptr[360 * sample.depth.info.width + 320]; c = ptr[240 * sample.depth.info.width + 160]; d = ptr[240 * sample.depth.info.width + 480]; // indexer = row*width + column; } if (found) { Output.text = "Pass"; } else { Output.text = "Fail"; } //-----EOUVM-----// /* Release the frame to process the next frame */ depthImage = sample.depth; psm.ReleaseFrame(); //---------------------EORS-------------------- }
/// <summary> /// Liefert den Wert (und neuen Offset) von der angegebenen Stelle im Byte-Array. /// </summary> /// <param name="Array"></param> /// <param name="Offset">Position, ab der gelesen wird.</param> unsafe static public (UInt16, Int32) CopyUInt16Offset(this byte [] Array, Int32 Offset) { fixed(byte *ptr = Array) { UInt16 *vpUInt16 = (UInt16 *)(ptr + Offset); return(*vpUInt16, Offset + sizeof(UInt16)); } }
/// <summary> /// Liefert den Wert von der angegebenen Stelle im Byte-Array. /// </summary> /// <param name="Array"></param> /// <param name="Offset"></param> unsafe static public UInt16 CopyUInt16(this byte [] Array, Int32 Offset) { fixed(byte *ptr = Array) { UInt16 *vpUInt16 = (UInt16 *)(ptr + Offset); return(*vpUInt16); } }
/// <summary> /// Kopiert die Werte einzeln via *ptr++. /// </summary> /// <param name="Source"></param> /// <param name="Target"></param> /// <param name="Length"></param> unsafe static public void CopyUInt16s(UInt16 *Source, UInt16 *Target, int Length) { for (int i = 0; i < Length; i++) { *Target = *Source; // Source++; Target++; } }
/// <summary> /// Kopiert den Wert an die angegebene Stelle in das Byte-Array. /// </summary> /// <param name="Array"></param> /// <param name="Offset">Position, ab der geschrieben wird. Erhöht sich um die Anzhal der gelesenen Bytes!</param> /// <param name="Value"></param> unsafe static public void CopyUInt16(this byte [] Array, ref Int32 Offset, UInt16 Value) { fixed(byte *ptr = Array) { UInt16 *vp = (UInt16 *)(ptr + Offset); *vp = Value; Offset += sizeof(UInt16); } }
/// <summary> /// Liefert die Bytes ab der Stelle <paramref name="Offset"/> als Wert. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="Array"></param> /// <param name="Offset">Position, ab der gelesen wird. Erhöht sich um die Anzhal der gelesenen Bytes!</param> /// <returns></returns> unsafe static public dynamic CopyValue <T> (this byte [] Array, ref Int32 Offset) where T : unmanaged { try { fixed(byte *ptr = Array) { switch (Type.GetTypeCode(typeof(T))) { case TypeCode.SByte: SByte *vpSByte = (SByte *)(ptr + Offset); return(*vpSByte); case TypeCode.Byte: Byte *vpByte = (Byte *)(ptr + Offset); return(*vpByte); case TypeCode.Int16: Int16 *vpInt16 = (Int16 *)(ptr + Offset); return(*vpInt16); case TypeCode.UInt16: UInt16 *vpUInt16 = (UInt16 *)(ptr + Offset); return(*vpUInt16); case TypeCode.Int32: Int32 *vpInt32 = (Int32 *)(ptr + Offset); return(*vpInt32); case TypeCode.UInt32: UInt32 *vpUInt32 = (UInt32 *)(ptr + Offset); return(*vpUInt32); case TypeCode.Int64: Int64 *vpInt64 = (Int64 *)(ptr + Offset); return(*vpInt64); case TypeCode.UInt64: UInt64 *vpUInt64 = (UInt64 *)(ptr + Offset); return(*vpUInt64); case TypeCode.Char: Char *vpChar = (Char *)(ptr + Offset); return(*vpChar); case TypeCode.Boolean: Boolean *vpBoolean = (Boolean *)(ptr + Offset); return(*vpBoolean); } } } finally { Offset += sizeof(T); } throw new Exception("Not implemented!"); }
/// <summary> /// maximum for all elements of A /// </summary> /// <param name="A">n-dim array</param> /// <returns><para>scalar maximum of all elements for A.</para> /// <para>If A is empty, an empty array will be returned.</para></returns> /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null.</exception> /// <seealso cref="ILNumerics.BuiltInFunctions.ILMath.max(ILArray<double>)"/> public static ILArray <UInt16> maxall(ILArray <UInt16> A) { if (object.Equals(A, null)) { throw new ILArgumentException("maxall: argument must not be null!"); } if (A.IsEmpty) { return(ILArray <UInt16> .empty(0, 0)); } UInt16 retArr = UInt16.MinValue; if (A.m_indexOffset == null) { unsafe { fixed(UInt16 *inArrStart = A.m_data) { UInt16 *inArrWalk = inArrStart; UInt16 *inArrEnd = inArrStart + A.Dimensions.NumberOfElements; while (inArrWalk < inArrEnd) { if (retArr < *inArrWalk) { retArr = *inArrWalk; } inArrWalk++; } } } } else { UInt16 tmp; unsafe { fixed(UInt16 *inArrStart = A.m_data) { for (int i = A.Dimensions.NumberOfElements; i-- > 0;) { tmp = *(inArrStart + A.getBaseIndex(i)); if (retArr < tmp) { retArr = tmp; } } } } } return(new ILArray <UInt16> (new UInt16 [1] { retArr }, 1, 1)); }
/// <summary> /// Kopiert den Wert an die angegebene Stelle in das Byte-Array und liefert den neuen Offset zurück. /// </summary> /// <param name="Array"></param> /// <param name="Offset"></param> /// <param name="Value"></param> /// <returns>Liefert den neuen Offset.</returns> unsafe static public Int32 CopyUInt16(this byte [] Array, Int32 Offset, UInt16 Value) { fixed(byte *ptr = Array) { UInt16 *vp = (UInt16 *)(ptr + Offset); *vp = Value; } return(Offset + sizeof(UInt16)); }