예제 #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<UInt16> A,  ILArray<UInt16> 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_uint16uint16 helper = new  oplogical_uint16uint16 ();
     return  LogicalBinaryUInt16Operator (A, B, helper.or);
 }
예제 #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<UInt16> A,  ILArray<UInt16> 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_uint16uint16 helper = new  oplogical_uint16uint16 ();
     return  LogicalBinaryUInt16Operator (A, B, helper.and);
 }