public float TotalPossessionInflation(int userID) { FloatObj value = TotalPossessionValue(userID); float percentage = PublicValues.InflationInARecentYear(); float price = value.Float * percentage; return(price); }
public override void Copy(int first, int count, Obj[] array, int destOffset) { int srcOffset = offset + first; for (int i = 0; i < count; i++) { array[destOffset + i] = new FloatObj(elts[srcOffset + i]); } }
//////////////////////////////////////////////////////////////////////////////// // If the function is successfull, it returns the index of the next token to consume // If it fails, it returns the location/index of the error, negated and decremented by one static long ParseObj(Token[] tokens, long offset, out Obj var) { int length = tokens.Length; if (offset >= length) { var = null; return(-offset - 1); } Token token = tokens[offset]; switch (token.type) { case TokenType.Comma: case TokenType.Colon: case TokenType.Semicolon: case TokenType.Arrow: case TokenType.ClosePar: case TokenType.CloseBracket: var = null; return(-offset - 1); case TokenType.Int: var = IntObj.Get((long)token.value); return(offset + 1); case TokenType.Float: var = new FloatObj((double)token.value); return(offset + 1); case TokenType.Symbol: return(ParseSymbOrTaggedObj(tokens, offset, out var)); case TokenType.OpenPar: if (IsRecord(tokens, offset)) { return(ParseRec(tokens, offset, out var)); } else { return(ParseSeq(tokens, offset, out var)); } case TokenType.OpenBracket: return(ParseUnordColl(tokens, offset, out var)); case TokenType.String: var = Miscellanea.StrToObj((string)token.value); return(offset + 1); default: var = null; throw new InvalidOperationException(); // Unreachable code } }
public void Update(int index, double value) { if (index >= column.Length) { column = Array.Extend(column, Array.Capacity(column.Length, index + 1), NULL); } if (IsNull(column[index])) { count++; } column[index] = FloatObj.IsNaN(value) ? FloatObj.NaN : value; }
public override uint Hashcode() { if (hcode == Hashing.NULL_HASHCODE) { ulong code = 0; int len = GetSize(); for (int i = 0; i < len; i++) { code = 31 * code + FloatObj.Hashcode(elts[offset + i]); } hcode = Hashing.Hashcode64(code); if (hcode == Hashing.NULL_HASHCODE) { hcode++; } } return(hcode); }
////////////////////////////////////////////////////////////////////////////// public void Insert(int index, double value) { if (index >= column.Length) { column = Array.Extend(column, Array.Capacity(column.Length, index + 1), NULL); } double currValue = column[index]; if (!IsNull(currValue)) { if (value != currValue) { throw ErrorHandler.SoftFail(); } } else { column[index] = FloatObj.IsNaN(value) ? FloatObj.NaN : value; count++; } }
////////////////////////////////////////////////////////////////////////////// public static Obj Copy(ColumnBase[] columns, bool flipCols) { int totalSize = 0; for (int i = 0; i < columns.Length; i++) { totalSize += columns[i].count; } if (totalSize == 0) { return(EmptyRelObj.singleton); } Obj[] objs1 = new Obj[totalSize]; Obj[] objs2 = new Obj[totalSize]; int next = 0; for (int i = 0; i < columns.Length; i++) { ColumnBase col = columns[i]; if (col is IntColumn) { IntColumn intCol = (IntColumn)col; IntColumn.Iter it = intCol.GetIter(); while (!it.Done()) { objs1[next] = intCol.mapper(it.GetIdx()); objs2[next] = IntObj.Get(it.GetValue()); next++; it.Next(); } } else if (col is FloatColumn) { FloatColumn floatCol = (FloatColumn)col; FloatColumn.Iter it = floatCol.GetIter(); while (!it.Done()) { objs1[next] = floatCol.mapper(it.GetIdx()); objs2[next] = new FloatObj(it.GetValue()); next++; it.Next(); } } else { ObjColumn objCol = (ObjColumn)col; ObjColumn.Iter it = objCol.GetIter(); while (!it.Done()) { objs1[next] = objCol.mapper(it.GetIdx()); objs2[next] = it.GetValue(); next++; it.Next(); } } } Debug.Assert(next == totalSize); if (flipCols) { Obj[] tmp = objs1; objs1 = objs2; objs2 = tmp; } return(Builder.CreateBinRel(objs1, objs2)); }
////////////////////////////////////////////////////////////////////////////// public FloatColumn(SurrObjMapper mapper) : base(mapper) { Debug.Assert(FloatObj.IsNaN(NULL)); Array.Fill(column, NULL); this.mapper = mapper; }