Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prod doesn't work with matrix and compressed_matrix #52

Open
albertz opened this issue Dec 13, 2013 · 1 comment
Open

prod doesn't work with matrix and compressed_matrix #52

albertz opened this issue Dec 13, 2013 · 1 comment

Comments

@albertz
Copy link
Contributor

albertz commented Dec 13, 2013

Code:

// c++ test_prod_sparse.cpp  -std=c++11

#include <viennacl/vector.hpp>
#include <viennacl/matrix.hpp>
#include <viennacl/compressed_matrix.hpp>
#include <viennacl/linalg/prod.hpp>
#include <viennacl/linalg/vector_operations.hpp>
#include <viennacl/linalg/matrix_operations.hpp>
#include <viennacl/scalar.hpp>
#include <viennacl/matrix_proxy.hpp>

int main() {
    using namespace viennacl;
    using namespace viennacl::linalg;

    auto a = matrix<float>(10,10);
    auto b = compressed_matrix<float>(10,10);
    auto v = prod(a, b);

    return 0;
}

Error:

az@azmacbookpro ~/P/N/NN-OCR> c++ test_prod_sparse.cpp  -std=c++11
test_prod_sparse.cpp:18:11: error: no matching function for call to 'prod'
        auto v = prod(a, b);
                 ^~~~
/usr/local/include/viennacl/linalg/prod.hpp:91:5: note: candidate template
      ignored: failed template argument deduction
    prod(std::vector< std::vector<T, A1>, A2 > const & matrix, VectorT c...
    ^
/usr/local/include/viennacl/linalg/prod.hpp:106:5: note: candidate template
      ignored: failed template argument deduction
    prod(std::vector< std::map<KEY, DATA, COMPARE, AMAP>, AVEC > const& ...
    ^
/usr/local/include/viennacl/linalg/prod.hpp:142:5: note: candidate template
      ignored: failed template argument deduction
    prod(viennacl::matrix_base<NumericT, F1> const & A,
    ^
/usr/local/include/viennacl/linalg/prod.hpp:158:5: note: candidate template
      ignored: failed template argument deduction
    prod(viennacl::matrix_base<NumericT, F1> const & A,
    ^
/usr/local/include/viennacl/linalg/prod.hpp:178:5: note: candidate template
      ignored: failed template argument deduction
    prod(viennacl::matrix_expression<const viennacl::matrix_base<NumericT, F1>,
    ^
/usr/local/include/viennacl/linalg/prod.hpp:201:5: note: candidate template
      ignored: failed template argument deduction
    prod(viennacl::matrix_expression<const viennacl::matrix_base<NumericT, F1>,
    ^
/usr/local/include/viennacl/linalg/prod.hpp:225:5: note: candidate template
      ignored: failed template argument deduction
    prod(viennacl::matrix_base<NumericT, F> const & matrix,
    ^
/usr/local/include/viennacl/linalg/prod.hpp:241:5: note: candidate template
      ignored: failed template argument deduction
    prod(viennacl::matrix_expression<const viennacl::matrix_base<NumericT, F>,
    ^
/usr/local/include/viennacl/linalg/prod.hpp:261:5: note: candidate template
      ignored: failed template argument deduction
    prod(const SparseMatrixType & mat,
    ^
/usr/local/include/viennacl/linalg/prod.hpp:275:5: note: candidate template
      ignored: failed template argument deduction
    prod(const SparseMatrixType & sp_mat,
    ^
/usr/local/include/viennacl/linalg/prod.hpp:292:5: note: candidate template
      ignored: failed template argument deduction
    prod(const SparseMatrixType & A,
    ^
/usr/local/include/viennacl/linalg/prod.hpp:310:5: note: candidate template
      ignored: failed template argument deduction
    prod(const StructuredMatrixType & mat,
    ^
1 error generated.
@karlrupp
Copy link
Collaborator

So far we only support a sparse first factor, i.e. in C = prod(A, B); only A can be sparse, not B or C. This has performance reasons, because one can only iterate quickly along rows of a sparse matrix, not along columns.

prod(B, A) with sparse A will only work reasonably well if the cost of transposing A in memory is substantially smaller than the cost of prod(B, A') where A' is the same as A but stored in column-major layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants