Exemple #1
0
 /// <summary>
 /// elementwise logical 'or' operator 
 /// </summary>
 /// <param name="A">input array A</param>
 /// <param name="B">input array B</param>
 /// <returns>logical array of same size as A and B, elements with result of logical 'or'.</returns>
 /// <remarks>A and B must have the same size or either one may be scalar.</remarks>
 public static ILLogicalArray or(/*!HC:inCls1*/ ILArray<double> A, /*!HC:inCls2*/ ILArray<double> B) {
     if (A == null || B == null) 
         throw new ILArgumentException ("ILMath.and: A and B must be matrices and cannot be null!");
     if (!A.Dimensions.IsSameShape(B.Dimensions)) 
         throw new ILArgumentException("input arrays must have the same size"); 
     if (A.IsEmpty || B.IsEmpty) 
         return ILLogicalArray.empty(A.Dimensions); 
     if (A.IsScalar) {
         if (A.GetValue(0) == 0) return B != 0.0; 
         return tological(ones(B.Dimensions));  
     } else if (B.IsScalar) {
         if (B.GetValue(0) == 0) return A != 0.0; 
         return tological(ones(A.Dimensions));  
     }
     /*!HC:ClsName*/ oplogical_doubledouble helper = new /*!HC:ClsName*/ oplogical_doubledouble ();
     return /*!HC:logicalbinaryop*/ LogicalBinaryDoubleOperator (A, B, helper.or);
 }
Exemple #2
0
 /// <summary>
 /// elementwise logical 'and' operator 
 /// </summary>
 /// <param name="A">input array A</param>
 /// <param name="B">input array B</param>
 /// <returns>logical array of same size as A and B, elements with result of logical 'and'.</returns>
 /// <remarks>A and B must have the same size or either one may be scalar. If one of A or B is empty, 
 /// an empty array of the same inner element type is returned.</remarks>
 public static ILLogicalArray and(/*!HC:inCls1*/ ILArray<double> A, /*!HC:inCls2*/ ILArray<double> B) {
     if (A == null || B == null) 
         throw new ILArgumentException ("ILMath.and: A and B must be matrices and cannot be null!");
     if (!A.Dimensions.IsSameShape(B.Dimensions)) 
         throw new ILArgumentException("input arrays must have the same size"); 
     if (A.IsEmpty || B.IsEmpty) 
         return ILLogicalArray.empty(A.Dimensions); 
     if (A.IsScalar) {
         if (A.GetValue(0) != 0) return B != 0.0; 
         byte[] ret = ILMemoryPool.Pool.New<byte>(B.Dimensions.NumberOfElements); 
         return new ILLogicalArray(ret, B.Dimensions,0); 
     } else if (B.IsScalar) {
         if (B.GetValue(0) != 0) return A != 0.0; 
         byte[] ret = ILMemoryPool.Pool.New<byte>(A.Dimensions.NumberOfElements); 
         return new ILLogicalArray(ret, A.Dimensions,0);
     }
     /*!HC:ClsName*/ oplogical_doubledouble helper = new /*!HC:ClsName*/ oplogical_doubledouble ();
     return /*!HC:logicalbinaryop*/ LogicalBinaryDoubleOperator (A, B, helper.and);
 }