32 # include <itpp/config.h>
34 # include <itpp/config_msvc.h>
37 #if defined (HAVE_BLAS)
38 # include <itpp/base/blas.h>
45 #if defined (HAVE_BLAS)
46 void copy_vector(
int n,
const double *x,
double *y)
49 blas::dcopy_(&n, x, &incr, y, &incr);
51 void copy_vector(
int n,
const std::complex<double> *x, std::complex<double> *y)
54 blas::zcopy_(&n, x, &incr, y, &incr);
57 void copy_vector(
int n,
const double *x,
double *y)
59 memcpy(y, x, static_cast<unsigned int>(n) *
sizeof(
double));
61 void copy_vector(
int n,
const std::complex<double> *x, std::complex<double> *y)
63 memcpy(y, x, static_cast<unsigned int>(n) *
sizeof(std::complex<double>));
68 #if defined (HAVE_BLAS)
69 void copy_vector(
int n,
const double *x,
int incx,
double *y,
int incy)
71 blas::dcopy_(&n, x, &incx, y, &incy);
73 void copy_vector(
int n,
const std::complex<double> *x,
int incx,
74 std::complex<double> *y,
int incy)
76 blas::zcopy_(&n, x, &incx, y, &incy);
79 void copy_vector(
int n,
const double *x,
int incx,
double *y,
int incy)
81 for (
int i = 0; i < n; i++)
82 y[i*incy] = x[i*incx];
84 void copy_vector(
int n,
const std::complex<double> *x,
int incx,
85 std::complex<double> *y,
int incy)
87 for (
int i = 0; i < n; i++)
88 y[i*incy] = x[i*incx];
93 #if defined (HAVE_BLAS)
94 void swap_vector(
int n,
double *x,
double *y)
97 blas::dswap_(&n, x, &incr, y, &incr);
99 void swap_vector(
int n, std::complex<double> *x, std::complex<double> *y)
102 blas::zswap_(&n, x, &incr, y, &incr);
105 void swap_vector(
int n,
double *x,
double *y)
107 for (
int i = 0; i < n; i++)
108 std::swap(x[i], y[i]);
110 void swap_vector(
int n, std::complex<double> *x, std::complex<double> *y)
112 for (
int i = 0; i < n; i++)
113 std::swap(x[i], y[i]);
118 #if defined (HAVE_BLAS)
119 void swap_vector(
int n,
double *x,
int incx,
double *y,
int incy)
121 blas::dswap_(&n, x, &incx, y, &incy);
123 void swap_vector(
int n, std::complex<double> *x,
int incx,
124 std::complex<double> *y,
int incy)
126 blas::zswap_(&n, x, &incx, y, &incy);
129 void swap_vector(
int n,
double *x,
int incx,
double *y,
int incy)
131 for (
int i = 0; i < n; i++)
132 std::swap(x[i*incx], y[i*incy]);
134 void swap_vector(
int n, std::complex<double> *x,
int incx,
135 std::complex<double> *y,
int incy)
137 for (
int i = 0; i < n; i++)
138 std::swap(x[i*incx], y[i*incy]);
143 #if defined(HAVE_BLAS)
144 void scal_vector(
int n,
double alpha,
double *x)
147 blas::dscal_(&n, &alpha, x, &incr);
149 void scal_vector(
int n, std::complex<double> alpha, std::complex<double> *x)
152 blas::zscal_(&n, &alpha, x, &incr);
155 void scal_vector(
int n,
double alpha,
double *x)
158 for (
int i = 0; i < n; ++i) {
163 void scal_vector(
int n, std::complex<double> alpha, std::complex<double> *x)
165 if (alpha != std::complex<double>(1.0)) {
166 for (
int i = 0; i < n; ++i) {
174 #if defined(HAVE_BLAS)
175 void scal_vector(
int n,
double alpha,
double *x,
int incx)
177 blas::dscal_(&n, &alpha, x, &incx);
179 void scal_vector(
int n, std::complex<double> alpha, std::complex<double> *x,
182 blas::zscal_(&n, &alpha, x, &incx);
185 void scal_vector(
int n,
double alpha,
double *x,
int incx)
188 for (
int i = 0; i < n; ++i) {
193 void scal_vector(
int n, std::complex<double> alpha, std::complex<double> *x,
196 if (alpha != std::complex<double>(1.0)) {
197 for (
int i = 0; i < n; ++i) {
205 #if defined(HAVE_BLAS)
206 void axpy_vector(
int n,
double alpha,
const double *x,
double *y)
209 blas::daxpy_(&n, &alpha, x, &incr, y, &incr);
211 void axpy_vector(
int n, std::complex<double> alpha,
212 const std::complex<double> *x, std::complex<double> *y)
215 blas::zaxpy_(&n, &alpha, x, &incr, y, &incr);
218 void axpy_vector(
int n,
double alpha,
const double *x,
double *y)
221 for (
int i = 0; i < n; ++i) {
222 y[i] += alpha * x[i];
226 for (
int i = 0; i < n; ++i) {
231 void axpy_vector(
int n, std::complex<double> alpha,
232 const std::complex<double> *x, std::complex<double> *y)
234 if (alpha != std::complex<double>(1.0)) {
235 for (
int i = 0; i < n; ++i) {
236 y[i] += alpha * x[i];
240 for (
int i = 0; i < n; ++i) {
248 #if defined(HAVE_BLAS)
249 void axpy_vector(
int n,
double alpha,
const double *x,
int incx,
double *y,
252 blas::daxpy_(&n, &alpha, x, &incx, y, &incy);
254 void axpy_vector(
int n, std::complex<double> alpha,
255 const std::complex<double> *x,
int incx,
256 std::complex<double> *y,
int incy)
258 blas::zaxpy_(&n, &alpha, x, &incx, y, &incy);
261 void axpy_vector(
int n,
double alpha,
const double *x,
int incx,
double *y,
265 for (
int i = 0; i < n; ++i) {
266 y[i*incy] += alpha * x[i*incx];
270 for (
int i = 0; i < n; ++i) {
271 y[i*incy] += x[i*incx];
275 void axpy_vector(
int n, std::complex<double> alpha,
276 const std::complex<double> *x,
int incx,
277 std::complex<double> *y,
int incy)
279 if (alpha != std::complex<double>(1.0)) {
280 for (
int i = 0; i < n; ++i) {
281 y[i*incy] += alpha * x[i*incx];
285 for (
int i = 0; i < n; ++i) {
286 y[i*incy] += x[i*incx];