21 #include <tensor/tensor.h>
25 template<
typename n>
inline
26 const Tensor<n> do_diag(
const Tensor<n> &a,
int which,
int rows,
int cols)
28 Tensor<n> output(rows, cols);
29 output.fill_with_zeros();
38 index l = std::min<index>(rows - r0, cols - c0);
40 std::cerr <<
"In diag(a,which,...) the value of WHICH exceeds the size of the matrix"
45 std::cerr <<
"In diag(a,...) the vector A has too few/many elements."
49 for (
size_t i = 0; i < (size_t)l; i++) {
50 output.at(r0+i,c0+i) = a[i];