public override void UnaryElementWiseOperation(NArray <double> a,
                                                       NArray <double> result, UnaryElementWiseOperation operation)
        {
            if (operation == VectorAccelerator.UnaryElementWiseOperation.Negate)
            {
                ScaleOffset(a, -1, 0, result);
                return;
            }
            VectorOperation vectorVectorOperation = null;

            switch (operation)
            {
            case VectorAccelerator.UnaryElementWiseOperation.CumulativeNormal: vectorVectorOperation = IntelMathKernelLibrary.CumulativeNormal; break;

            case VectorAccelerator.UnaryElementWiseOperation.Exp: vectorVectorOperation = IntelMathKernelLibrary.Exp; break;

            case VectorAccelerator.UnaryElementWiseOperation.InverseCumulativeNormal: vectorVectorOperation = IntelMathKernelLibrary.InverseCumulativeNormal; break;

            case VectorAccelerator.UnaryElementWiseOperation.InverseSquareRoot: vectorVectorOperation = IntelMathKernelLibrary.InverseSquareRoot; break;

            case VectorAccelerator.UnaryElementWiseOperation.Inverse: vectorVectorOperation = IntelMathKernelLibrary.Inverse; break;

            case VectorAccelerator.UnaryElementWiseOperation.Log: vectorVectorOperation = IntelMathKernelLibrary.Log; break;

            case VectorAccelerator.UnaryElementWiseOperation.SquareRoot: vectorVectorOperation = IntelMathKernelLibrary.SquareRoot; break;
            }
            VectorOperation(a, result, vectorVectorOperation);
        }
        //#region Unary Operations

        public virtual NArray <T> UnaryElementWiseOperation <T>(NArray <T> operand, UnaryElementWiseOperation operation)
        {
            var result = NewNArrayLike(operand);

            DoUnaryElementWiseOperation <T>(operand, result, operation);
            return(result);
        }
        public override NArray <T> UnaryElementWiseOperation <T>(NArray <T> operand,
                                                                 UnaryElementWiseOperation operation)
        {
            NArray <T> result = null;

            if (operand.IsScalar)
            {
                Func <T, T> scalarOperation = null;
                switch (operation)
                {
                case VectorAccelerator.UnaryElementWiseOperation.Negate:
                    scalarOperation = (op) => { T res; Negate <T>(op, out res); return(res); };
                    break;
                //case VectorAccelerator.UnaryElementWiseOperation.Exp:

                default:
                    throw new NotImplementedException();
                }
                if (!IsIndependentVariable(operand))
                {
                    return(NewScalarNArray(scalarOperation(operand.First())));
                }
                else
                {
                    result = NewScalarLocalNArray(scalarOperation(operand.First()), true);
                }
            }
            else
            {
                result = NewNArrayLike(operand);
            }
            DoUnaryElementWiseOperation <T>(operand, result, operation);

            return(result);
        }
Exemplo n.º 4
0
 public void AddUnaryElementWiseOperation <T>(NArray <T> a,
                                              NArray <T> result, UnaryElementWiseOperation operation)
 {
     _operations.Add(
         Expression.Assign(GetParameter <T>(result),
                           ExpressionExtended.MakeUnary(operation, GetParameter <T>(a)))
         );
 }
Exemplo n.º 5
0
 public abstract void UnaryElementWiseOperation(NArray <int> a, NArray <int> result, UnaryElementWiseOperation operation);
Exemplo n.º 6
0
 public static UnaryMathsExpression MakeUnary(UnaryElementWiseOperation unaryType, VectorParameterExpression operand)
 {
     return(new UnaryMathsExpression(unaryType, operand));
 }
Exemplo n.º 7
0
 internal UnaryMathsExpression(UnaryElementWiseOperation unaryType, VectorParameterExpression operand)
 {
     UnaryType = unaryType;
     Operand   = operand;
 }
Exemplo n.º 8
0
 public override void DoUnaryElementWiseOperation <T>(NArray <T> a, NArray <T> result, UnaryElementWiseOperation operation)
 {
     ElementWise <T>(a).UnaryElementWiseOperation(a, result, operation);
 }
 public override void UnaryElementWiseOperation(NArray <int> a,
                                                NArray <int> result, UnaryElementWiseOperation operation)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 10
0
 public abstract void DoUnaryElementWiseOperation <T>(NArray <T> a, NArray <T> result, UnaryElementWiseOperation operation);
 public override void DoUnaryElementWiseOperation <T>(NArray <T> a, NArray <T> result, UnaryElementWiseOperation operation)
 {
     _builder.AddUnaryElementWiseOperation(a, result, operation);
 }