// Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "paddle/fluid/operators/math/lapack_function.h" #include "paddle/fluid/platform/complex.h" #include "paddle/fluid/platform/dynload/lapack.h" namespace paddle { namespace operators { namespace math { // LU (for example) template <> void lapackLu(int m, int n, double *a, int lda, int *ipiv, int *info) { platform::dynload::dgetrf_(&m, &n, a, &lda, ipiv, info); } template <> void lapackLu(int m, int n, float *a, int lda, int *ipiv, int *info) { platform::dynload::sgetrf_(&m, &n, a, &lda, ipiv, info); } // Eig template <> void lapackEig(char jobvl, char jobvr, int n, double *a, int lda, double *w, double *vl, int ldvl, double *vr, int ldvr, double *work, int lwork, double *rwork, int *info) { double *wr = w; double *wi = w + n; (void)rwork; // unused platform::dynload::dgeev_(&jobvl, &jobvr, &n, a, &lda, wr, wi, vl, &ldvl, vr, &ldvr, work, &lwork, info); } template <> void lapackEig(char jobvl, char jobvr, int n, float *a, int lda, float *w, float *vl, int ldvl, float *vr, int ldvr, float *work, int lwork, float *rwork, int *info) { float *wr = w; float *wi = w + n; (void)rwork; // unused platform::dynload::sgeev_(&jobvl, &jobvr, &n, a, &lda, wr, wi, vl, &ldvl, vr, &ldvr, work, &lwork, info); } template <> void lapackEig, double>( char jobvl, char jobvr, int n, platform::complex *a, int lda, platform::complex *w, platform::complex *vl, int ldvl, platform::complex *vr, int ldvr, platform::complex *work, int lwork, double *rwork, int *info) { platform::dynload::zgeev_( &jobvl, &jobvr, &n, reinterpret_cast *>(a), &lda, reinterpret_cast *>(w), reinterpret_cast *>(vl), &ldvl, reinterpret_cast *>(vr), &ldvr, reinterpret_cast *>(work), &lwork, rwork, info); } template <> void lapackEig, float>( char jobvl, char jobvr, int n, platform::complex *a, int lda, platform::complex *w, platform::complex *vl, int ldvl, platform::complex *vr, int ldvr, platform::complex *work, int lwork, float *rwork, int *info) { platform::dynload::cgeev_( &jobvl, &jobvr, &n, reinterpret_cast *>(a), &lda, reinterpret_cast *>(w), reinterpret_cast *>(vl), &ldvl, reinterpret_cast *>(vr), &ldvr, reinterpret_cast *>(work), &lwork, rwork, info); } } // namespace math } // namespace operators } // namespace paddle