Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
 }