Ejemplo n.º 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( ILArray<complex> A,  ILArray<complex> 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));  
     }
     oplogical_complexcomplex helper = new  oplogical_complexcomplex ();
     return  LogicalBinaryComplexOperator (A, B, helper.or);
 }
Ejemplo n.º 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( ILArray<complex> A,  ILArray<complex> 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);
     }
     oplogical_complexcomplex helper = new  oplogical_complexcomplex ();
     return  LogicalBinaryComplexOperator (A, B, helper.and);
 }