public void CloneTest() { var exp = new Pow(Variable.X, new Number(0)); var clone = exp.Clone(); Assert.Equal(exp, clone); }
public BlockHeader Clone() { return(new BlockHeader { Version = Version, Height = Height, Previous = Previous.Clone(), Timestamp = Timestamp, UtxoRoot = UtxoRoot.Clone(), RangeProofRoot = RangeProofRoot.Clone(), KernelRoot = KernelRoot.Clone(), Nonce = Nonce, Pow = Pow.Clone(), Difficulty = Difficulty.Clone(), TotalDifficulty = TotalDifficulty.Clone() }); }
/// <summary> /// Analyzes the specified expression. /// </summary> /// <param name="exp">The expression.</param> /// <returns> /// The result of analysis. /// </returns> public override IExpression Analyze(Pow exp) { if (!Helpers.HasVariable(exp, Variable)) { return(new Number(0)); } if (Helpers.HasVariable(exp.Left, Variable)) { var sub = new Sub(exp.Right.Clone(), new Number(1)); var inv = new Pow(exp.Left.Clone(), sub); var mul1 = new Mul(exp.Right.Clone(), inv); var mul2 = new Mul(exp.Left.Clone().Analyze(this), mul1); return(mul2); } // if (Helpers.HasVar(exp.Right, variable)) var ln = new Ln(exp.Left.Clone()); var mul3 = new Mul(ln, exp.Clone()); var mul4 = new Mul(mul3, exp.Right.Clone().Analyze(this)); return(mul4); }