/** * <p> * Creates a reflector from the provided vector and gamma.<br> * <br> * Q = I - γ u u<sup>H</sup><br> * </p> * * @param u A vector. Not modified. * @param gamma To produce a reflector gamma needs to be equal to 2/||u||. * @return An orthogonal reflector. */ public static CMatrixRMaj createReflector(CMatrixRMaj u, float gamma) { if (!MatrixFeatures_CDRM.isVector(u)) { throw new ArgumentException("u must be a vector"); } CMatrixRMaj Q = CommonOps_CDRM.identity(u.getNumElements()); CommonOps_CDRM.multAddTransB(-gamma, 0, u, u, Q); return(Q); }
/** * <p> * Creates a reflector from the provided vector.<br> * <br> * Q = I - γ u u<sup>T</sup><br> * γ = 2/||u||<sup>2</sup> * </p> * * @param u A vector. Not modified. * @return An orthogonal reflector. */ public static CMatrixRMaj createReflector(CMatrixRMaj u) { if (!MatrixFeatures_CDRM.isVector(u)) { throw new ArgumentException("u must be a vector"); } float norm = NormOps_CDRM.normF(u); float gamma = -2.0f / (norm * norm); CMatrixRMaj Q = CommonOps_CDRM.identity(u.getNumElements()); CommonOps_CDRM.multAddTransB(gamma, 0, u, u, Q); return(Q); }