1 // This file is part of Eigen, a lightweight C++ template library
4 // Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 int EIGEN_BLAS_FUNC(axpy
)(const int *n
, const RealScalar
*palpha
, const RealScalar
*px
, const int *incx
, RealScalar
*py
, const int *incy
)
14 const Scalar
* x
= reinterpret_cast<const Scalar
*>(px
);
15 Scalar
* y
= reinterpret_cast<Scalar
*>(py
);
16 Scalar alpha
= *reinterpret_cast<const Scalar
*>(palpha
);
20 if(*incx
==1 && *incy
==1) make_vector(y
,*n
) += alpha
* make_vector(x
,*n
);
21 else if(*incx
>0 && *incy
>0) make_vector(y
,*n
,*incy
) += alpha
* make_vector(x
,*n
,*incx
);
22 else if(*incx
>0 && *incy
<0) make_vector(y
,*n
,-*incy
).reverse() += alpha
* make_vector(x
,*n
,*incx
);
23 else if(*incx
<0 && *incy
>0) make_vector(y
,*n
,*incy
) += alpha
* make_vector(x
,*n
,-*incx
).reverse();
24 else if(*incx
<0 && *incy
<0) make_vector(y
,*n
,-*incy
).reverse() += alpha
* make_vector(x
,*n
,-*incx
).reverse();
29 int EIGEN_BLAS_FUNC(copy
)(int *n
, RealScalar
*px
, int *incx
, RealScalar
*py
, int *incy
)
33 Scalar
* x
= reinterpret_cast<Scalar
*>(px
);
34 Scalar
* y
= reinterpret_cast<Scalar
*>(py
);
36 // be carefull, *incx==0 is allowed !!
37 if(*incx
==1 && *incy
==1)
38 make_vector(y
,*n
) = make_vector(x
,*n
);
41 if(*incx
<0) x
= x
- (*n
-1)*(*incx
);
42 if(*incy
<0) y
= y
- (*n
-1)*(*incy
);
54 int EIGEN_CAT(EIGEN_CAT(i
,SCALAR_SUFFIX
),amax_
)(int *n
, RealScalar
*px
, int *incx
)
57 Scalar
* x
= reinterpret_cast<Scalar
*>(px
);
60 if(*incx
==1) make_vector(x
,*n
).cwiseAbs().maxCoeff(&ret
);
61 else make_vector(x
,*n
,std::abs(*incx
)).cwiseAbs().maxCoeff(&ret
);
65 int EIGEN_CAT(EIGEN_CAT(i
,SCALAR_SUFFIX
),amin_
)(int *n
, RealScalar
*px
, int *incx
)
68 Scalar
* x
= reinterpret_cast<Scalar
*>(px
);
71 if(*incx
==1) make_vector(x
,*n
).cwiseAbs().minCoeff(&ret
);
72 else make_vector(x
,*n
,std::abs(*incx
)).cwiseAbs().minCoeff(&ret
);
76 int EIGEN_BLAS_FUNC(rotg
)(RealScalar
*pa
, RealScalar
*pb
, RealScalar
*pc
, RealScalar
*ps
)
81 Scalar
& a
= *reinterpret_cast<Scalar
*>(pa
);
82 Scalar
& b
= *reinterpret_cast<Scalar
*>(pb
);
84 Scalar
* s
= reinterpret_cast<Scalar
*>(ps
);
90 if((aa
+ab
)==Scalar(0))
100 Scalar amax
= aa
>ab
? a
: b
;
106 if (ab
> aa
&& *c
!=RealScalar(0))
113 RealScalar norm
,scale
;
114 if(abs(a
)==RealScalar(0))
122 scale
= abs(a
) + abs(b
);
123 norm
= scale
*sqrt((numext::abs2(a
/scale
)) + (numext::abs2(b
/scale
)));
126 *s
= alpha
*numext::conj(b
)/norm
;
131 // JacobiRotation<Scalar> r;
132 // r.makeGivens(a,b);
139 int EIGEN_BLAS_FUNC(scal
)(int *n
, RealScalar
*palpha
, RealScalar
*px
, int *incx
)
143 Scalar
* x
= reinterpret_cast<Scalar
*>(px
);
144 Scalar alpha
= *reinterpret_cast<Scalar
*>(palpha
);
146 if(*incx
==1) make_vector(x
,*n
) *= alpha
;
147 else make_vector(x
,*n
,std::abs(*incx
)) *= alpha
;
152 int EIGEN_BLAS_FUNC(swap
)(int *n
, RealScalar
*px
, int *incx
, RealScalar
*py
, int *incy
)
156 Scalar
* x
= reinterpret_cast<Scalar
*>(px
);
157 Scalar
* y
= reinterpret_cast<Scalar
*>(py
);
159 if(*incx
==1 && *incy
==1) make_vector(y
,*n
).swap(make_vector(x
,*n
));
160 else if(*incx
>0 && *incy
>0) make_vector(y
,*n
,*incy
).swap(make_vector(x
,*n
,*incx
));
161 else if(*incx
>0 && *incy
<0) make_vector(y
,*n
,-*incy
).reverse().swap(make_vector(x
,*n
,*incx
));
162 else if(*incx
<0 && *incy
>0) make_vector(y
,*n
,*incy
).swap(make_vector(x
,*n
,-*incx
).reverse());
163 else if(*incx
<0 && *incy
<0) make_vector(y
,*n
,-*incy
).reverse().swap(make_vector(x
,*n
,-*incx
).reverse());