public MCell Initialize() { if (value == null) { value = MFullArray <double> .CreateEmpty(); } return(this); }
public static int GetForSliceCount(MValue value) { Contract.Requires(value != null); var shape = value.shape; var count = shape.Count; return(count == 0 ? 0 : (count / shape.RowCount)); }
public static bool IsTrue(MValue value) { // "An evaluated expression is true when the result is nonempty // and contains all nonzero elements (logical or real numeric). // Otherwise, the expression is false." Contract.Requires(value != null); var type = value.Repr; if (type.IsComplex) { return(false); } if (type.IsArray) { int count = value.Count; if (count == 0) { return(false); } var doubleArray = value as MFullArray <double>; if (doubleArray != null) { for (int i = 0; i < count; ++i) { if (!(doubleArray[i] != 0)) { return(false); } } return(true); } var logicalArray = value as MFullArray <bool>; if (logicalArray != null) { for (int i = 0; i < count; ++i) { if (!logicalArray[i]) { return(false); } } return(true); } } throw new NotImplementedException(); }
public MCell(MValue value) { Contract.Requires(value != null); this.value = value; }