level1_real_impl.h
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
00005 //
00006 // Eigen is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 3 of the License, or (at your option) any later version.
00010 //
00011 // Alternatively, you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License as
00013 // published by the Free Software Foundation; either version 2 of
00014 // the License, or (at your option) any later version.
00015 //
00016 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
00017 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00018 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
00019 // GNU General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License and a copy of the GNU General Public License along with
00023 // Eigen. If not, see <http://www.gnu.org/licenses/>.
00024 
00025 #include "common.h"
00026 
00027 // computes the sum of magnitudes of all vector elements or, for a complex vector x, the sum
00028 // res = |Rex1| + |Imx1| + |Rex2| + |Imx2| + ... + |Rexn| + |Imxn|, where x is a vector of order n
00029 RealScalar EIGEN_BLAS_FUNC(asum)(int *n, RealScalar *px, int *incx)
00030 {
00031 //   std::cerr << "_asum " << *n << " " << *incx << "\n";
00032 
00033   Scalar* x = reinterpret_cast<Scalar*>(px);
00034 
00035   if(*n<=0) return 0;
00036 
00037   if(*incx==1)  return vector(x,*n).cwiseAbs().sum();
00038   else          return vector(x,*n,std::abs(*incx)).cwiseAbs().sum();
00039 }
00040 
00041 // computes a vector-vector dot product.
00042 Scalar EIGEN_BLAS_FUNC(dot)(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
00043 {
00044 //   std::cerr << "_dot " << *n << " " << *incx << " " << *incy << "\n";
00045 
00046   if(*n<=0) return 0;
00047 
00048   Scalar* x = reinterpret_cast<Scalar*>(px);
00049   Scalar* y = reinterpret_cast<Scalar*>(py);
00050 
00051   if(*incx==1 && *incy==1)    return (vector(x,*n).cwiseProduct(vector(y,*n))).sum();
00052   else if(*incx>0 && *incy>0) return (vector(x,*n,*incx).cwiseProduct(vector(y,*n,*incy))).sum();
00053   else if(*incx<0 && *incy>0) return (vector(x,*n,-*incx).reverse().cwiseProduct(vector(y,*n,*incy))).sum();
00054   else if(*incx>0 && *incy<0) return (vector(x,*n,*incx).cwiseProduct(vector(y,*n,-*incy).reverse())).sum();
00055   else if(*incx<0 && *incy<0) return (vector(x,*n,-*incx).reverse().cwiseProduct(vector(y,*n,-*incy).reverse())).sum();
00056   else return 0;
00057 }
00058 
00059 // computes the Euclidean norm of a vector.
00060 // FIXME
00061 Scalar EIGEN_BLAS_FUNC(nrm2)(int *n, RealScalar *px, int *incx)
00062 {
00063 //   std::cerr << "_nrm2 " << *n << " " << *incx << "\n";
00064   if(*n<=0) return 0;
00065 
00066   Scalar* x = reinterpret_cast<Scalar*>(px);
00067 
00068   if(*incx==1)  return vector(x,*n).stableNorm();
00069   else          return vector(x,*n,std::abs(*incx)).stableNorm();
00070 }
00071 
00072 int EIGEN_BLAS_FUNC(rot)(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy, RealScalar *pc, RealScalar *ps)
00073 {
00074 //   std::cerr << "_rot " << *n << " " << *incx << " " << *incy << "\n";
00075   if(*n<=0) return 0;
00076 
00077   Scalar* x = reinterpret_cast<Scalar*>(px);
00078   Scalar* y = reinterpret_cast<Scalar*>(py);
00079   Scalar c = *reinterpret_cast<Scalar*>(pc);
00080   Scalar s = *reinterpret_cast<Scalar*>(ps);
00081 
00082   StridedVectorType vx(vector(x,*n,std::abs(*incx)));
00083   StridedVectorType vy(vector(y,*n,std::abs(*incy)));
00084 
00085   Reverse<StridedVectorType> rvx(vx);
00086   Reverse<StridedVectorType> rvy(vy);
00087 
00088        if(*incx<0 && *incy>0) internal::apply_rotation_in_the_plane(rvx, vy, JacobiRotation<Scalar>(c,s));
00089   else if(*incx>0 && *incy<0) internal::apply_rotation_in_the_plane(vx, rvy, JacobiRotation<Scalar>(c,s));
00090   else                        internal::apply_rotation_in_the_plane(vx, vy,  JacobiRotation<Scalar>(c,s));
00091 
00092 
00093   return 0;
00094 }
00095 
00096 /*
00097 // performs rotation of points in the modified plane.
00098 int EIGEN_BLAS_FUNC(rotm)(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy, RealScalar *param)
00099 {
00100   Scalar* x = reinterpret_cast<Scalar*>(px);
00101   Scalar* y = reinterpret_cast<Scalar*>(py);
00102 
00103   // TODO
00104 
00105   return 0;
00106 }
00107 
00108 // computes the modified parameters for a Givens rotation.
00109 int EIGEN_BLAS_FUNC(rotmg)(RealScalar *d1, RealScalar *d2, RealScalar *x1, RealScalar *x2, RealScalar *param)
00110 {
00111   // TODO
00112 
00113   return 0;
00114 }
00115 */


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:31:38