This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| EIGEN_STRONG_INLINE Matrix &normalize() { | |
| *this /= norm(); | |
| return *this; | |
| } | |
| EIGEN_STRONG_INLINE Scalar length() const { return norm(); } | |
| EIGEN_STRONG_INLINE Matrix &vectorize(Scalar v) { | |
| fill(v); | |
| return *this; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| #include <stdexcept> | |
| #include <cassert> | |
| #include <Windows.h> | |
| template<typename Signature, char *(*GetFunctionName)(), HMODULE &(*GetDllHandle)()> | |
| struct DllFunction { | |
| DllFunction() : _functionPtr(reinterpret_cast<Signature*>(GetProcAddress(GetDllHandle(), GetFunctionName()))) { | |
| if (_functionPtr == NULL) throw std::runtime_error("Dll function cannot be loaded."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void CircularShiftLeft(ref uint value, int shift, int sizeInBits = BitsInInt32) { | |
| Contract.Requires(sizeInBits > 0 && sizeInBits <= BitsInInt32); | |
| Contract.Requires(shift <= sizeInBits && shift >= 0); | |
| uint mask = UInt32.MaxValue >> (BitsInInt32 - sizeInBits); | |
| uint masked = value & mask; | |
| uint shifted = (masked << shift) | (masked >> (sizeInBits - shift)); | |
| value = (value & ~mask) | (shifted & mask); | |
| } | |
| public static void CircularShiftRight(ref uint value, int shift, int sizeInBits = BitsInInt32) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static byte[] StructureToByteArray<T>(T obj) { | |
| int len = Marshal.SizeOf(typeof (T)); | |
| var arr = new byte[len]; | |
| IntPtr ptr = IntPtr.Zero; | |
| try { | |
| ptr = Marshal.AllocHGlobal(len); | |
| Marshal.StructureToPtr(obj, ptr, true); | |
| Marshal.Copy(ptr, arr, 0, len); | |
| } | |
| finally { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class RadioButtonBinder { | |
| public static readonly DependencyProperty ValueProperty = | |
| DependencyProperty.RegisterAttached("Value", typeof (object), typeof (RadioButtonBinder), | |
| new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.NotDataBindable, ValueChanged)); | |
| public static readonly DependencyProperty BindProperty = | |
| DependencyProperty.RegisterAttached("Bind", typeof (object), typeof (RadioButtonBinder), | |
| new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, BindChanged)); | |
| private static bool _react = true; |