Boost logo

Ublas :

Subject: Re: [ublas] Problem creating mapping from string to vector_expression
From: Nasos Iliopoulos (nasos_i_at_[hidden])
Date: 2017-03-30 14:43:58


I don't think what you are trying to achieve is possible. The reason is that when you try to instantiate anything of the form:

unordered_map<std::string, vector_expression <T> >

it will turn to be a type like:

unordered_map<std::string, vector_expression < vector<container<vector<int>>> >

So "c" will only be able to deal with vector<int>.

To achieve what you want you probably need to use a variant type in your unordered_map (like std::any), or fiddle with unsafe type casts.

-Nasos

On 03/30/2017 10:21 AM, SHIVAM MITTAL via ublas wrote:
I want the mapping to be vector_expressions only. Using vector_expression and not a real vector, means we can algorithmically build a data.frame from the results of other computations.

On Thu, Mar 30, 2017 at 7:31 PM, Nasos Iliopoulos via ublas <ublas_at_[hidden]<mailto:ublas_at_[hidden]>> wrote:

It would be kind of convolved to try to cast an ublas vector to a vector expression. Will the following achieve what you want?

#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <unordered_map>
#include <string>
#include <iostream>

int main()
{
    std::unordered_map<std::string, boost::numeric::ublas::vector<int> > c;

    boost::numeric::ublas::vector<int> v (10);
    for (unsigned i = 0; i < v.size (); ++ i)
        v (i) = i;

    c["first"] = v;

    std::cout << c["first"] << std::endl;
    return 0;
}

On 03/30/2017 09:30 AM, SHIVAM MITTAL via ublas wrote:
vector<int> v (10);
for (unsigned i = 0; i < v.size (); ++ i)
v (i) = i;

_______________________________________________
ublas mailing list
ublas_at_[hidden]<mailto:ublas_at_[hidden]>
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: 2015csb1032_at_[hidden]<mailto:2015csb1032_at_[hidden]>

_______________________________________________
ublas mailing list
ublas_at_[hidden]<mailto:ublas_at_[hidden]>
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: athanasios.iliopoulos.ctr.gr_at_[hidden]<mailto:athanasios.iliopoulos.ctr.gr_at_[hidden]>