Fork me on GitHub
 All Classes Files Functions Variables Groups Pages
blas.cu
#include <cusp/array2d.h>
#include <cusp/blas/blas.h>
#include <cusp/print.h>
#include <iostream>
int main(void)
{
// initialize x vector
x[0] = 1;
x[1] = 2;
// initialize y vector
y[0] = 1;
y[1] = 2;
// compute y = alpha * x + y
// print y
// allocate output vector
// compute z = x .* y (element-wise multiplication)
// print z
// compute the l_2 norm of z in 2 different ways
std::cout << "|z| = " << cusp::blas::nrm2(z) << std::endl;
std::cout << "sqrt(z'z) = " << sqrt(cusp::blas::dotc(z,z)) << std::endl;
// compute the l_1 norm of z (manhattan distance)
std::cout << "|z|_1 = " << cusp::blas::nrm1(z) << std::endl;
// compute the largest component of a vector in absolute value
std::cout << "max(|z_i|) = " << cusp::blas::nrmmax(z) << std::endl;
return 0;
}