blitzpp / blitz

Blitz++ Multi-Dimensional Array Library for C++
https://github.com/blitzpp/blitz/wiki
Other
404 stars 83 forks source link

[bug?] sum can not be written in same line as Array instantiation #116

Closed ClmnsRck closed 5 years ago

ClmnsRck commented 5 years ago
blitz::Array<T, 2> x = sum(A(a,b)*B(b,c),b);

This does not work, and throws this error. If this is wanted behaviour, just close the issue.

src/aBlitz.hpp:207:28: error: conversion from ‘blitz::_bz_ArrayExpr<blitz::_bz_ArrayExprReduce<blitz::_bz_ArrayExpr<blitz::_bz_ArrayExprBinaryOp<blitz::_bz_ArrayExpr<blitz::ArrayIndexMapping<blitz::_bz_ArrayExpr<blitz::FastArrayIterator<float, 2> >, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0> >, blitz::_bz_ArrayExpr<blitz::ArrayIndexMapping<blitz::_bz_ArrayExpr<blitz::FastArrayIterator<float, 2> >, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0> >, blitz::Multiply<float, float> > >, 2, blitz::ReduceSum<float, double> > >’ to non-scalar type ‘blitz::Array<float, 2>’ requested
         blitz::Array<T, 2> tmp3 = blitz::sum(tmp1(a,b)*x(c,b),b);
lutorm commented 5 years ago

Correct. This is intended behavior. The target array needs to have a size, because that array is what determines the externt of the index traversals of the expression. You also need to specify the storage order and allocation policy, which isn't possible in your example.

On Tue, Apr 16, 2019 at 1:38 AM ClmnsRck notifications@github.com wrote:

blitz::Array<T, 2> x = sum(A(a,b)*B(b,c),b);

This does not work, and throws this error. If this is wanted behaviour, just close the issue.

src/aBlitz.hpp:207:28: error: conversion from ‘blitz::_bz_ArrayExpr<blitz::_bz_ArrayExprReduce<blitz::_bz_ArrayExpr<blitz::_bz_ArrayExprBinaryOp<blitz::_bz_ArrayExpr<blitz::ArrayIndexMapping<blitz::_bz_ArrayExpr<blitz::FastArrayIterator<float, 2> >, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0> >, blitz::_bz_ArrayExpr<blitz::ArrayIndexMapping<blitz::_bz_ArrayExpr<blitz::FastArrayIterator<float, 2> >, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0> >, blitz::Multiply<float, float> > >, 2, blitz::ReduceSum<float, double> > >’ to non-scalar type ‘blitz::Array<float, 2>’ requested

     blitz::Array<T, 2> tmp3 = blitz::sum(tmp1(a,b)*x(c,b),b);

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/blitzpp/blitz/issues/116, or mute the thread https://github.com/notifications/unsubscribe-auth/AFK8GPgC0s1kwaJPO-kqGXFTYwa8l1ohks5vhbYlgaJpZM4cyBpA .

ClmnsRck commented 5 years ago

ok, Then i will close this issue. Thank you