MCPcopy Create free account
hub / github.com/QuEST-Kit/QuEST / getWhetherRealsAreStrictlyNonNegative

Function getWhetherRealsAreStrictlyNonNegative

quest/src/core/utilities.cpp:712–734  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

710 */
711
712bool getWhetherRealsAreStrictlyNonNegative(qcomp* diags, qindex dim) {
713
714 /// @todo
715 /// consider multithreading or GPU-accelerating this
716 /// when caller is big and e.g. has GPU memory
717
718 // it may seem like this function should be combined with
719 // getWhetherRealsAreApproxNonZero() above, or indeed with
720 // getHermiticity(), since all three are relevant to vali-
721 // dation of diagonl matrices which can be exponentiated.
722 // Alas, such as design is complicated by this particular
723 // property (non-negativeness) being independent of the
724 // validation epsilon. For example, sometimes it needs to
725 // be computed even when numerical validation is disabled,
726 // and does not need recomputing with the epsilon changes.
727
728 // check every real component is strictly >= 0
729 for (qindex i=0; i<dim; i++)
730 if (std::real(diags[i]) < 0)
731 return false;
732
733 return true;
734}
735
736// non-negativity of fixed-size matrices is always computed afresh
737bool util_isStrictlyNonNegative(DiagMatr1 m) { return getWhetherRealsAreStrictlyNonNegative(m.elems, m.numElems); }

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected