public void Rank2Test() { AType expected = AArray.Create(ATypes.AFloat, AArray.Create(ATypes.AFloat, AFloat.Create(1), AFloat.Create(-1)), AArray.Create(ATypes.AFloat, AFloat.Create(-0.5), AFloat.Create(1)) ); AType result = this.engine.Execute <AType>("mdiv 2 2 rho 2 2 1 2"); Assert.AreEqual(expected, result); }
public void ReplicateInteger2Null() { AType expected = AArray.Create( ATypes.ANull ); AType result = this.engine.Execute <AType>("3 / ()"); Assert.AreEqual(expected, result); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
public void NegateMatrix() { AType expected = AArray.Create(ATypes.AInteger, AArray.Create(ATypes.AInteger, AInteger.Create(0), AInteger.Create(-1)), AArray.Create(ATypes.AInteger, AInteger.Create(-2), AInteger.Create(-3)) ); AType result = this.engine.Execute <AType>(" - iota 2 2"); Assert.AreEqual(expected, result); }
public void DropInteger2FloatList() { AType expected = AArray.Create( ATypes.AFloat ); AType result = this.engine.Execute <AType>("6 drop 2.5 4 5"); Assert.AreEqual(expected, result); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
public void IntervalFloatTolerablyInteger() { AType expected = AArray.Create(ATypes.AInteger, AInteger.Create(0), AInteger.Create(1), AInteger.Create(2), AInteger.Create(3) ); AType result = this.engine.Execute <AType>("iota 4.0"); Assert.AreEqual(expected, result); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
public void DropInteger2FunctionList() { AType expected = AArray.Create( ATypes.ANull ); AType result = this.engine.Execute <AType>(" 3 drop (+;-)"); Assert.AreEqual(expected, result); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
public void Serialize(AObject serializer) { serializer.Write(KEY_NAME, Name); AArray queries = serializer.WriteArray(KEY_QUERIES); for (int x = 0; x < Queries.Count; x++) { queries.Write(Queries[x]); } }
public void EqualToMatrix2Matrix() { AType expected = AArray.Create(ATypes.AInteger, AArray.Create(ATypes.AInteger, AInteger.Create(1), AInteger.Create(1)), AArray.Create(ATypes.AInteger, AInteger.Create(1), AInteger.Create(1)) ); AType result = this.engine.Execute <AType>("(iota 2 2) = iota 2 2"); Assert.AreEqual(expected, result); }
public void EqualToInteger2Strand() { AType expected = AArray.Create(ATypes.AInteger, AInteger.Create(0), AInteger.Create(0) ); AType result = this.engine.Execute <AType>("1 = (1;3)"); Assert.AreEqual(expected, result); }
public void ExpandNull2Float() { AType expected = AArray.Create( ATypes.AFloat ); AType result = this.engine.Execute <AType>("() \\ 3.4"); Assert.AreEqual(expected, result); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
public void MultipleSimpleIndexing() { AType expected = AArray.Create(ATypes.AInteger, AInteger.Create(1), AInteger.Create(2) ); AType result = this.engine.Execute <AType>("(0 1 2 3)[1 2]"); Assert.AreEqual(expected, result, "Incorrect value assigned"); }
public void DivideMatrix2Matrix() { AType expected = AArray.Create(ATypes.AFloat, AArray.Create(ATypes.AFloat, AFloat.Create(0), AFloat.Create(1 / 2.0)), AArray.Create(ATypes.AFloat, AFloat.Create(2 / 3.0), AFloat.Create(3 / 4.0)) ); AType result = this.engine.Execute <AType>("(iota 2 2) % 2 2 rho 1 2 3 4"); Assert.AreEqual(expected, result); }
public void TakeZeroCount() { AType expected = AArray.Create( ATypes.AInteger ); AType result = this.engine.Execute <AType>("0 take 1 2 3"); Assert.AreEqual(expected, result); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
public void ReadAndLocalWriteIntegerArray() { AType expected = AArray.Create( ATypes.AInteger, AArray.Create( ATypes.AInteger, AInteger.Create(5), AInteger.Create(6), AInteger.Create(7) ), AArray.Create( ATypes.AInteger, AInteger.Create(8), AInteger.Create(2), AInteger.Create(7) ) ); ScriptScope scope = this.engine.CreateScope(); string value = string.Format("1 beam `{0}", MappedFiles.IntegerMatrix.GetFileName()); this.engine.Execute <AType>(string.Format("a := {0}", value), scope); this.engine.Execute <AType>(string.Format("b := {0}", value), scope); this.engine.Execute <AType>("(1 drop a) := 1 3 rho 8 2 7", scope); Assert.AreEqual(InfoResult.OK, scope.GetVariable <AType>(".a").CompareInfos(expected)); Assert.AreEqual(expected, scope.GetVariable <AType>(".a")); Assert.AreEqual(InfoResult.OK, scope.GetVariable <AType>(".b").CompareInfos(expected)); Assert.AreEqual(expected, scope.GetVariable <AType>(".b")); this.engine.Execute <AType>("((1;0) # b) := 45", scope); expected = AArray.Create( ATypes.AInteger, AArray.Create( ATypes.AInteger, AInteger.Create(5), AInteger.Create(6), AInteger.Create(7) ), AArray.Create( ATypes.AInteger, AInteger.Create(45), AInteger.Create(2), AInteger.Create(7) ) ); Assert.AreEqual(InfoResult.OK, scope.GetVariable <AType>(".a").CompareInfos(expected)); Assert.AreEqual(expected, scope.GetVariable <AType>(".a")); Assert.AreEqual(InfoResult.OK, scope.GetVariable <AType>(".b").CompareInfos(expected)); Assert.AreEqual(expected, scope.GetVariable <AType>(".b")); }
public void TakeInteger2Integer() { AType expected = AArray.Create( ATypes.AInteger, AInteger.Create(5) ); AType result = this.engine.Execute <AType>("1 take 5"); Assert.AreEqual(expected, result); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
public void CorrectCase1() { AType expected = AArray.Create(ATypes.AInteger, AArray.Create(ATypes.AInteger, AInteger.Create(1), AInteger.Create(1)), AArray.Create(ATypes.AInteger, AInteger.Create(1), AInteger.Create(1)) ); AType result = this.engine.Execute <AType>("_index{2 2 rho 1; 1 1; 1}"); Assert.AreEqual(expected, result); }
public void RazeStrandFirstFloatNull() { AType expected = AArray.Create(ATypes.AFloat, AFloat.Create(3.3), AFloat.Create(4) ); AType result = this.engine.Execute <AType>("pick (0 rho 3.5;3.3;4;)"); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); Assert.AreEqual(expected, result); }
public void ExpandOne2CharacterConstant() { AType expected = AArray.Create( ATypes.AChar, AChar.Create('a') ); AType result = this.engine.Execute <AType>("1 \\ 'a'"); Assert.AreEqual(expected, result); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
public void DivideVector2Vector() { AType expected = AArray.Create(ATypes.AFloat, AFloat.Create(0 / 10.0), AFloat.Create(12 / -7.0), AFloat.Create(-4 / 4.0) ); AType result = this.engine.Execute <AType>("0 12 -4 % 10.0 -7 4.0"); Assert.AreEqual(expected, result); }
public void BitwiseNotEqualVector() { AType expected = AArray.Create(ATypes.AInteger, AInteger.Create(9), AInteger.Create(96), AInteger.Create(1005) ); AType result = this.engine.Execute <AType>("10 100 1000 bwne 3 4 5"); Assert.AreEqual(expected, result); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
/// <summary> /// Execute 'dyadic' Each algorithm. /// </summary> /// <param name="left"></param> /// <param name="right"></param> /// <param name="environment"></param> /// <param name="isNull"></param> /// <param name="function"></param> /// <returns></returns> private AType Walker(AType left, AType right, Aplus environment, bool isNull, AFunc function) { if (left.IsArray) { AType result = AArray.Create(ATypes.AArray); AType rightArray = right.IsArray ? right : AArray.Create(right.Type, right); for (int i = 0; i < left.Length; i++) { result.AddWithNoUpdate(Walker(left[i], rightArray[right.IsArray ? i : 0], environment, isNull, function)); } result.Type = isNull ? ATypes.ANull : ATypes.ABox; result.Length = left.Length; result.Shape = new List <int>(left.Shape); result.Rank = left.Rank; return(result); } else { if (right.IsArray) { AType result = AArray.Create(ATypes.AArray); for (int i = 0; i < right.Length; i++) { result.AddWithNoUpdate(Walker(left, right[i], environment, isNull, function)); } result.Type = isNull ? ATypes.ANull : ATypes.ABox; result.Length = right.Length; result.Shape = new List <int>(right.Shape); result.Rank = right.Rank; return(result); } else { //Disclose left and right scalar argument. AType disclosedRight = MonadicFunctionInstance.Disclose.Execute(right, environment); AType disclosedLeft = MonadicFunctionInstance.Disclose.Execute(left, environment); var method = (Func <Aplus, AType, AType, AType>)function.Method; //Execute the holden function and enclose the result. AType result = method(environment, disclosedRight, disclosedLeft); result = MonadicFunctionInstance.Enclose.Execute(result); return(result); } } }
internal static AType PermissiveIndexing(Aplus environment, AType defaultItem, AType array, AType index) { PermissiveIndexingErrorCheck(index, array, defaultItem); if (index.Type == ATypes.ANull) { return(AArray.Create(ATypes.ANull)); } return(PermissiveIndexingSubIndex(index, array, defaultItem, environment)); }
public void DivideVector2Integer() { AType expected = AArray.Create(ATypes.AFloat, AFloat.Create(0), AFloat.Create(2 / 3.0), AFloat.Create(4 / 3.0) ); AType result = this.engine.Execute <AType>("0 2 4 % 3"); Assert.AreEqual(expected, result); }
public void DivideInteger2Vector() { AType expected = AArray.Create(ATypes.AFloat, AFloat.Create(double.PositiveInfinity), AFloat.Create(1), AFloat.Create(2 / 4.0) ); AType result = this.engine.Execute <AType>("2 % 0 2 4"); Assert.AreEqual(expected, result); }
protected override void Serialize(AObject serializer) { base.Serialize(serializer); AArray entries = serializer.WriteArray(KEY_HISTORY); for (int x = 0; x < m_ExecutionHistory.Count; x++) { entries.Write(m_ExecutionHistory[x]); } }
public void SymbolArgument() { AType expected = AArray.Create(ATypes.ABox, ABox.Create(ASymbol.Create("symbol")), ABox.Create(ABox.Create(Utils.ANull())) ); AType result = this.engine.Execute <AType>("_alsf{`symbol}"); Assert.AreEqual(expected, result); }
public void ExpandNull2SymbolConstant() { AType expected = AArray.Create( ATypes.ASymbol, ASymbol.Create("") ); AType result = this.engine.Execute <AType>("0 \\ `test"); Assert.AreEqual(expected, result); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
public void AppendTypeError() { ScriptScope scope = this.engine.CreateScope(); scope.SetVariable( ".a", AArray.Create(ATypes.AInteger, AInteger.Create(1), AInteger.Create(2)) ); this.engine.Execute <AType>("a[,] := 'd'", scope); }
public void IntegerVectorMember() { AType expected = AArray.Create(ATypes.AInteger, AInteger.Create(1), AInteger.Create(0) ); AType result = this.engine.Execute <AType>("1 0 in 1"); Assert.AreEqual <AType>(expected, result, "Invalid value produced"); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
public void BoxArgument() { AType expected = AArray.Create(ATypes.ABox, ABox.Create(AArray.Create(ATypes.ANull)), ABox.Create(AArray.Create(ATypes.ANull)) ); AType result = this.engine.Execute <AType>("_alsf{<()}"); Assert.AreEqual(expected, result); }