public static string GetComplexType(VTYPE t) { switch (t) { case VTYPE.TYPE_QUATERNION: return("Quaternion"); case VTYPE.TYPE_ROTATION: return("Matrix3"); case VTYPE.TYPE_VECTOR4: return("Vector4"); case VTYPE.TYPE_MATRIX4: return("Matrix4"); case VTYPE.TYPE_MATRIX3: return("Matrix3"); case VTYPE.TYPE_TRANSFORM: return("Transform"); case VTYPE.TYPE_QSTRANSFORM: return("QSTransform"); case VTYPE.TYPE_CSTRING: case VTYPE.TYPE_STRINGPTR: return("StringPointer"); default: return(null); } }
public static string GetEnumType(VTYPE t, string ename) { switch (t) { case VTYPE.TYPE_INT8: return($@"SByte"); case VTYPE.TYPE_UINT8: return($@"Byte"); case VTYPE.TYPE_INT16: return($@"Int16"); case VTYPE.TYPE_UINT16: return($@"UInt16"); case VTYPE.TYPE_INT32: return($@"Int32"); case VTYPE.TYPE_UINT32: return($@"UInt32"); default: throw new Exception("Unimplemented type"); } }
public static string GetSimpleType(VTYPE t) { switch (t) { case VTYPE.TYPE_BOOL: return("Boolean"); case VTYPE.TYPE_CHAR: case VTYPE.TYPE_INT8: return("SByte"); case VTYPE.TYPE_UINT8: return("Byte"); case VTYPE.TYPE_INT16: case VTYPE.TYPE_HALF: return("Int16"); case VTYPE.TYPE_UINT16: return("UInt16"); case VTYPE.TYPE_INT32: return("Int32"); case VTYPE.TYPE_UINT32: return("UInt32"); case VTYPE.TYPE_INT64: case VTYPE.TYPE_LONG: return("Int64"); case VTYPE.TYPE_UINT64: case VTYPE.TYPE_ULONG: return("UInt64"); case VTYPE.TYPE_REAL: return("Single"); default: return(null); } }
public static string ReduceType(HKXMember m, VTYPE t, bool v = false) { string r; if (t == VTYPE.TYPE_ENUM) { r = m.EType; } else if (t == VTYPE.TYPE_CSTRING) { r = "string"; } else if (t == VTYPE.TYPE_STRINGPTR) { r = "string"; } else if (t == VTYPE.TYPE_UINT8) { r = "byte"; } else if (t == VTYPE.TYPE_INT8) { r = "sbyte"; } else if (t == VTYPE.TYPE_CHAR) { r = "sbyte"; } else if (t == VTYPE.TYPE_UINT16) { r = "ushort"; } else if (t == VTYPE.TYPE_INT16) { r = "short"; } else if (t == VTYPE.TYPE_HALF) { r = "short"; } else if (t == VTYPE.TYPE_UINT32) { r = "uint"; } else if (t == VTYPE.TYPE_INT32) { r = "int"; } else if (t == VTYPE.TYPE_ULONG) { r = "ulong"; } else if (t == VTYPE.TYPE_UINT64) { r = "ulong"; } else if (t == VTYPE.TYPE_LONG) { r = "long"; } else if (t == VTYPE.TYPE_INT64) { r = "long"; } else if (t == VTYPE.TYPE_INT32) { r = "int"; } else if (t == VTYPE.TYPE_BOOL) { r = "bool"; } else if (t == VTYPE.TYPE_FLAGS) { r = ReduceType(m, m.VSubType, true); } else if (t == VTYPE.TYPE_REAL) { r = "float"; } else if (t == VTYPE.TYPE_QUATERNION) { r = "Quaternion"; } else if (t == VTYPE.TYPE_ROTATION) { r = "Matrix4x4"; } else if (t == VTYPE.TYPE_VECTOR4) { r = "Vector4"; } else if (t == VTYPE.TYPE_MATRIX4) { r = "Matrix4x4"; } else if (t == VTYPE.TYPE_MATRIX3) { r = "Matrix4x4"; } else if (t == VTYPE.TYPE_TRANSFORM) { r = "Matrix4x4"; } else if (t == VTYPE.TYPE_QSTRANSFORM) { r = "Matrix4x4"; } else if (t == VTYPE.TYPE_POINTER) { if (v) { if (m.CType != null) { r = m.CType; } else { r = "void*"; } return(r); } r = ReduceType(m, m.VSubType, true); } else if (t == VTYPE.TYPE_ARRAY) { r = "List<" + ReduceType(m, m.VSubType, true) + ">"; } else if (t == VTYPE.TYPE_RELARRAY) { r = "List<" + ReduceType(m, m.VSubType, true) + ">"; } else if (t == VTYPE.TYPE_SIMPLEARRAY) { r = "List<" + ReduceType(m, m.VSubType, true) + ">"; } else if (t == VTYPE.TYPE_STRUCT) { r = m.CType; } else if (t == VTYPE.TYPE_VARIANT) { r = "ulong"; } else { throw new Exception("Unknown type"); } return(r); }
public static uint MemberSize(HKXMember m, VTYPE t, bool v = false) { var adjarrsize = m.ArraySize; if (v || adjarrsize == 0) { adjarrsize = 1; } if (t == VTYPE.TYPE_ENUM) { return(MemberSize(m, m.VSubType, true)); //return 4; // Almost always 4 bytes regardless of vsubtype? } else if (t == VTYPE.TYPE_CSTRING) { return(POINTER_SIZE); } else if (t == VTYPE.TYPE_STRINGPTR) { return(POINTER_SIZE); } else if (t == VTYPE.TYPE_UINT8) { return(1 * adjarrsize); } else if (t == VTYPE.TYPE_INT8) { return(1 * adjarrsize); } else if (t == VTYPE.TYPE_CHAR) { return(1 * adjarrsize); } else if (t == VTYPE.TYPE_UINT16) { return(2 * adjarrsize); } else if (t == VTYPE.TYPE_INT16) { return(2 * adjarrsize); } else if (t == VTYPE.TYPE_HALF) { return(2 * adjarrsize); } else if (t == VTYPE.TYPE_UINT32) { return(4 * adjarrsize); } else if (t == VTYPE.TYPE_INT32) { return(4 * adjarrsize); } else if (t == VTYPE.TYPE_ULONG) { return(8 * adjarrsize); } else if (t == VTYPE.TYPE_UINT64) { return(8 * adjarrsize); } else if (t == VTYPE.TYPE_LONG) { return(8 * adjarrsize); } else if (t == VTYPE.TYPE_INT64) { return(8 * adjarrsize); } else if (t == VTYPE.TYPE_INT32) { return(4 * adjarrsize); } else if (t == VTYPE.TYPE_BOOL) { return(1 * adjarrsize); } else if (t == VTYPE.TYPE_FLAGS) { return(MemberSize(m, m.VSubType, true)); } else if (t == VTYPE.TYPE_REAL) { return(4 * adjarrsize); } else if (t == VTYPE.TYPE_QUATERNION) { return(16 * adjarrsize); } else if (t == VTYPE.TYPE_ROTATION) { return(48 * adjarrsize); } else if (t == VTYPE.TYPE_VECTOR4) { return(16 * adjarrsize); } else if (t == VTYPE.TYPE_MATRIX4) { return(64 * adjarrsize); } else if (t == VTYPE.TYPE_MATRIX3) { return(48 * adjarrsize); } else if (t == VTYPE.TYPE_TRANSFORM) { return(64 * adjarrsize); } else if (t == VTYPE.TYPE_QSTRANSFORM) { return(64 * adjarrsize); } else if (t == VTYPE.TYPE_POINTER) { return(POINTER_SIZE * adjarrsize); } else if (t == VTYPE.TYPE_ARRAY) { return(16); } else if (t == VTYPE.TYPE_RELARRAY) { return(4); } else if (t == VTYPE.TYPE_SIMPLEARRAY) { return(16); // ? } else if (t == VTYPE.TYPE_STRUCT) { return(Classes[m.CType].Size * adjarrsize); } else if (t == VTYPE.TYPE_VARIANT) { return(8); // Don't really care for this } throw new Exception("Unknown type"); }
public void Reset(bool isTerminal, int tag, int subtagCounts) { this.tag = tag; this.TYPE = isTerminal ? VTYPE.TERMINAL : VTYPE.NONTERMINAL; this.posteriorScore = isTerminal ? 0.0f : double.NegativeInfinity; this.posteriorViterbiAlpha = isTerminal ? 0.0f : double.NegativeInfinity; this.subtagCount = subtagCounts; if (isTerminal && subtagCount != 1) { throw new Exception("terminal vertex cannot have subtags!"); } alpha.Length = subtagCounts; beta.Length = subtagCounts; Array.Clear (pruned, 0, pruned.Length); if (!isTerminal) { for (int i = 0; i < _alpha.Length; ++i) { _alpha [i] = double.NegativeInfinity; } } else { Array.Clear (_alpha, 0, _alpha.Length); } for (int i = 0; i < _beta.Length; ++i) { _beta [i] = double.NegativeInfinity; } InDegree = 0; OutDegree = 0; first = null; last = null; }
//public IEnumerable<HyperEdge> OutgoingEdges //{ // get // { // foreach (var e in outgoings) // { // yield return e; // } // } //} public void Purge() { foreach (var edge in incomings) { edge.Purge (); } TYPE = VTYPE.DEAD; }
/// <summary> /// Prune away subtag which has score lower than thr; /// Return the count of survived subtags. /// </summary> /// <param name="thr"></param> /// <returns></returns> public int Prune(double thr) { int surviveCount = 0; for (int i = 0; i < subtagCount; ++i) { if (!pruned [i]) { if (_alpha [i] + _beta [i] < thr) { pruned [i] = true; } else { surviveCount += 1; } } } if (surviveCount == 0) { TYPE = VTYPE.DEAD; } return surviveCount; }
public void Clear() { first = null; last = null; InDegree = 0; OutDegree = 0; posteriorViterbiEdge = null; TYPE = VTYPE.DEAD; traces = null; }