示例#1
0
 // Initialize ADouble variable from double
 public ADouble(double doubleValue)
 {
     AADType         = (int)AADUtility.AADCalculationType.Const;
     Value           = doubleValue;
     PlacementInTape = AADTape._tapeCounter;
     AADTape.AddEntry((int)AADType, PlacementInTape, 0, 0, Value);
 }
示例#2
0
        public static ADouble Pow(ADouble x1, double exponent)
        {
            ADouble temp = new ADouble();

            temp.Value           = Math.Pow(x1.Value, exponent);
            temp.PlacementInTape = AADTape._tapeCounter;
            AADTape.AddEntry((int)AADUtility.AADCalculationType.Pow, x1.PlacementInTape, 0, 0, temp.Value, exponent);
            return(temp);
        }
示例#3
0
        public static ADouble Exp(ADouble x1)
        {
            ADouble Temp = new ADouble();

            Temp.Value           = Math.Exp(x1.Value);
            Temp.PlacementInTape = AADTape._tapeCounter;
            AADTape.AddEntry((int)AADUtility.AADCalculationType.Exp, x1.PlacementInTape, 0, 0, Temp.Value);
            return(Temp);
        }
示例#4
0
        public static ADouble Log(ADouble x1)
        {
            ADouble temp = new ADouble();

            temp.Value           = Math.Log(x1.Value);
            temp.PlacementInTape = AADTape._tapeCounter;
            AADTape.AddEntry((int)AADUtility.AADCalculationType.Log, x1.PlacementInTape, 0, 0, temp.Value);
            return(temp);
        }
示例#5
0
        public static ADouble operator /(double K, ADouble x)
        {
            ADouble temp = new MasterThesis.ADouble();

            temp.Value           = K / x.Value;
            temp.PlacementInTape = AADTape._tapeCounter;
            AADTape.AddEntry((int)AADUtility.AADCalculationType.ConsDiv, x.PlacementInTape, 0, 0, temp.Value, K);
            return(temp);
        }
示例#6
0
        public static ADouble operator /(ADouble x1, ADouble x2)
        {
            ADouble temp = new ADouble();

            temp.Value           = x1.Value / x2.Value;
            temp.PlacementInTape = AADTape._tapeCounter;
            AADTape.AddEntry((int)AADUtility.AADCalculationType.Div, x1.PlacementInTape, x2.PlacementInTape, 0, temp.Value);
            return(temp);
        }
示例#7
0
        public static ADouble operator -(double K, ADouble x)
        {
            ADouble temp = new ADouble();

            temp.Value           = K - x.Value;
            temp.PlacementInTape = AADTape._tapeCounter;
            AADTape.AddEntry((int)AADUtility.AADCalculationType.ConsSubInverse, x.PlacementInTape, 0, 0, temp.Value, K);
            return(temp);
        }
示例#8
0
        public static ADouble operator +(ADouble x, double K)
        {
            ADouble temp = new ADouble();

            temp.Value           = x.Value + K;
            temp.PlacementInTape = AADTape._tapeCounter;
            AADTape.AddEntry((int)AADUtility.AADCalculationType.ConsAdd, x.PlacementInTape, 0, 0, temp.Value, K);
            return(temp);
        }
示例#9
0
        public static ADouble operator /(ADouble x, double K)
        {
            // Note that we store this as a "ConsMul" on the tape
            ADouble temp = new MasterThesis.ADouble();

            temp.Value           = x.Value / K;
            temp.PlacementInTape = AADTape._tapeCounter;
            AADTape.AddEntry((int)AADUtility.AADCalculationType.ConsMul, x.PlacementInTape, 0, 0, temp.Value, 1 / K);
            return(temp);
        }
示例#10
0
 // Assign ADouble to the tape. This is used when instantiating the tape.
 public void Assign()
 {
     PlacementInTape = AADTape._tapeCounter;
     AADTape.AddEntry((int)AADUtility.AADCalculationType.Const, AADTape._tapeCounter, 0, 0, Value);
 }