Boost logo

Ublas :

Subject: Re: [ublas] size_type for mapped_matrix
From: Alex Hagen-Zanker (ahh34_at_[hidden])
Date: 2011-04-13 17:20:57


Dear Jörn,

.
  On 13/04/2011 18:19, Ungermann, Jörn wrote:
> Hi,
>
> I think you are right in your observation that mapped_matrix is not consistent there.
>
> Do you really have a sparse matrix with more than 2^32 non-zero entries? That would imply that you have about one third of non-zeros. I am not sure that a sparse approach is then still the most efficient one.
>
  I do not have that many non-zero entries. The matrix dimensions are
120 000 * 120 000 but the number of non-zero entries is about 60000.

The problem is not the number of entries a std::map can hold, but the
size of the indices themselves. I can provide a std::map that uses long
unsigned int as the key, but internally mapped_matrix sticks with size_t
and hence produces wrong results.

> However, I'd use coordinate_matrix for construction, as inserting elements is *much* cheaper than for mapped_matrix, especially if you have more than 2^32 entries.
>
> ublas::coordinate_matrix<double, ublas::row_major, 0, ublas::unbounded_array<long unsigned int, MyAllocator>
> > MyTypeName;
>
> You still have the problem then that unbounded_array uses size_t internally to manage the memory, which will probably a problem for you? The only way around *that* is writing your own allocator (MyAllocator above), as std::allocator also uses size_t.
Your suggestion of using a coordinate matrix works very well, except for
a large amount of warnings about casts of long int to size_t that I ignore.

Thanks for your help, Alex

>> -----Original Message-----
>> From: ublas-bounces_at_[hidden] [mailto:ublas-
>> bounces_at_[hidden]] On Behalf Of Alex Hagen-Zanker
>> Sent: Mittwoch, 13. April 2011 11:08
>> To: ublas_at_[hidden]
>> Subject: [ublas] size_type for mapped_matrix
>>
>> Dear All,
>>
>> I am using a mapped_matrix as a sparse matrix for a matrix with
>> dimensions 120 000 * 120 000. As this exceeds the limits of size_t I
>> thought to step away from the default template parameters and use:
>>
>> mapped_matrix<double, row_major, map_std<long long, double> >
>> myMatrix
>>
>> This does not solve my problem as the mapped_matrix::size_type is still
>> size_t. Looking at the ublas source code I see that
>> mapped_matrix::size_type boils down to std::map<long long,
>> double>::size_type.
>>
>> It seems to me that this should be std::map<long long,
>> double>::key_type
>> instead.
>>
>> Is this a bug, or am I expecting too much?
>>
>> Can I use one of the other sparse matrix types instead?
>>
>> Thanks, Alex
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> ublas mailing list
>> ublas_at_[hidden]
>> http://lists.boost.org/mailman/listinfo.cgi/ublas
>> Sent to: j.ungermann_at_[hidden]
> ------------------------------------------------------------------------------------------------
> ------------------------------------------------------------------------------------------------
> Forschungszentrum Juelich GmbH
> 52425 Juelich
> Sitz der Gesellschaft: Juelich
> Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
> Vorsitzender des Aufsichtsrats: MinDirig Dr. Karl Eugen Huthmacher
> Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
> Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
> Prof. Dr. Sebastian M. Schmidt
> ------------------------------------------------------------------------------------------------
> ------------------------------------------------------------------------------------------------
>
> Besuchen Sie uns auf unserem neuen Webauftritt unter www.fz-juelich.de
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
> Sent to: ahh34_at_[hidden]

-- 
Alex Hagen-Zanker
University of Cambridge, Department of Architecture,  1-5 Scroope Terrace, Cambridge, CB2 1PX, United Kingdom
Tel: +44(0) 1223 330573