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

Initializer list constructor for vector #63

Closed
NAThompson opened this issue Dec 5, 2018 · 4 comments
Closed

Initializer list constructor for vector #63

NAThompson opened this issue Dec 5, 2018 · 4 comments

Comments

@NAThompson
Copy link

NAThompson commented Dec 5, 2018

Initializer list constructors are not supported for ublas vector (error message from g++ 8):

 error: no matching function for call to 'boost::numeric::ublas::vector<double>::vector(<brace-enclosed initializer list>)'
     boost::numeric::ublas::vector<double> w{1,2,3,4,5,6,7};

It would be a convenient enhancement, and presumably easy to implement.

@bassoy
Copy link
Collaborator

bassoy commented Mar 4, 2019

@NAThompson , thanks for your interest in uBLAS. This will be supported soon! We are making a transition from 2D to ND and also major changes to comply with C++11 and newer standards, see example.

@NAThompson
Copy link
Author

Awesome! Looks like y'all are doing really cool stuff.

@bassoy
Copy link
Collaborator

bassoy commented Apr 12, 2020

Thanks.

@bassoy bassoy closed this as completed Apr 12, 2020
@bradbell
Copy link

@bassoy This does not seem to work on Fedora 38 (which uses version 1.78.0 of boost). See
https://bugzilla.redhat.com/show_bug.cgi?id=2223035

Would you please try the shell script below (boost_vector.sh) to see if the corresponding test works for you:

#! /usr/bin/env bash
set -u -e
if [ $# != 1 ]
then
   echo 'usage: ./boost_vector.sh (std|boost)'
   exit 1
fi
if [ "$1" == 'std' ]
then
   vector_type="std::vector<double>"
else
   vector_type="boost::numeric::ublas::vector<double>"
fi
cat << EOF > boost_vector.cpp
# include <vector>
# include <boost/numeric/ublas/vector.hpp>

int main(void)
{  $vector_type v = { 1.0, 2.0 };
   if( v.size() == 2 && v[0] == 1.0 && v[1] == 2.0 )
      return 0;
   return 1;
}
EOF
g++ boost_vector.cpp -o boost_vector
if ! ./boost_vector
then
   echo 'boost_vector: Error'
   exit 1
fi
#
echo 'boost_vector: OK'
exit 0

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

3 participants