Boost logo

Ublas :

Subject: [ublas] vectors, contiguous storage
From: Tiago Requeijo (tiago.requeijo.dev_at_[hidden])
Date: 2009-06-05 09:55:52


Is there any guarantee about contiguous storage of ublas vectors (or
matrices for what matters)?

The specific case I'm thinking about is the following:

double SomeFunction( const vector<double>& v )
    double* ptr = &([0]);
    (do something with ptr)

When is it the case that *(ptr+i) is equal to v(i)?

This seems to work fine when called on a declared variable of vector type,
but fails for slices of matrices (as it should since the data is not

Is there any way of knowing whether the storage of v in the function above
is contiguous or not?