// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2012 Chen-Pang He // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef STORMEIGEN_SELFADJOINT_PACKED_PRODUCT_H #define STORMEIGEN_SELFADJOINT_PACKED_PRODUCT_H namespace internal { /* Optimized matrix += alpha * uv' * The matrix is in packed form. */ template struct selfadjoint_packed_rank1_update; template struct selfadjoint_packed_rank1_update { typedef typename NumTraits::Real RealScalar; static void run(Index size, Scalar* mat, const Scalar* vec, RealScalar alpha) { typedef Map > OtherMap; typedef typename conj_expr_if::type ConjRhsType; conj_if cj; for (Index i=0; i >(mat, UpLo==Lower ? size-i : (i+1)) += alpha * cj(vec[i]) * ConjRhsType(OtherMap(vec+(UpLo==Lower ? i : 0), UpLo==Lower ? size-i : (i+1))); //FIXME This should be handled outside. mat[UpLo==Lower ? 0 : i] = numext::real(mat[UpLo==Lower ? 0 : i]); mat += UpLo==Lower ? size-i : (i+1); } } }; template struct selfadjoint_packed_rank1_update { typedef typename NumTraits::Real RealScalar; static void run(Index size, Scalar* mat, const Scalar* vec, RealScalar alpha) { selfadjoint_packed_rank1_update::run(size,mat,vec,alpha); } }; } // end namespace internal #endif // STORMEIGEN_SELFADJOINT_PACKED_PRODUCT_H