Lars Schouw | 21 May 10:06
Picon
Favicon

boost:multi_array and assign

Is there any easy way to assign values to a boost::multi_array?

boost::multi_array<double, 2> abd(boost::extents[4][33]);
abd[0][0] = 1.00;    abd[0][1] = 0.00;    abd[0][2] = 0.00;    abd[0][3] = 0.10;
..

I would like to do 

abd = boost::assign::list_of(1.00)(0.00)(0.00)(0.10)

But realize this might be a little more tricky with higher dimensions but still possible.

Lars

      
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Thorsten Ottosen | 21 May 20:25
Favicon

Re: boost:multi_array and assign

Lars Schouw skrev:
> Is there any easy way to assign values to a boost::multi_array?
> 
> boost::multi_array<double, 2> abd(boost::extents[4][33]);
> abd[0][0] = 1.00;    abd[0][1] = 0.00;    abd[0][2] = 0.00;    abd[0][3] = 0.10;
> ...
> 
> 
> I would like to do 
> 
> abd = boost::assign::list_of(1.00)(0.00)(0.00)(0.10)
> 
> But realize this might be a little more tricky with higher dimensions but still possible.
> 

What do you want to do with non-provided values? Zero-initialize them?

-Thorsten
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Steven Watanabe | 22 May 06:48
Picon

Re: boost:multi_array and assign

AMDG

Thorsten Ottosen wrote:
> Lars Schouw skrev:
>   
>> Is there any easy way to assign values to a boost::multi_array?
>>
>> boost::multi_array<double, 2> abd(boost::extents[4][33]);
>> abd[0][0] = 1.00;    abd[0][1] = 0.00;    abd[0][2] = 0.00;    abd[0][3] = 0.10;
>> ...
>>
>>
>> I would like to do 
>>
>> abd = boost::assign::list_of(1.00)(0.00)(0.00)(0.10)
>>
>> But realize this might be a little more tricky with higher dimensions but still possible.
>>
>>     
>
> What do you want to do with non-provided values? Zero-initialize them?
>   

If they are going to be initialized, that's probably the most consistent
choice, given that it is what the compiler does for

double c_array[10] = { 1.0 };

The other options are
* resize the multi_array
(Continue reading)


Gmane