Boost logo

Boost Users :

Subject: Re: [Boost-users] multi-array and pdes
From: Pierre-Andre Noel (noel.pierre.andre_at_[hidden])
Date: 2011-05-22 14:06:25


Hi Petros,

Yes, you could use fortran_storage_order as a starting point.

I'm not sure I understand the problem. Can't you use array_ref as your
views? Here is an example (not tested), given the hypothetical
"cyclic_storage_order".

boost::multi_array<value_type,3> A(boost::extents[L][M][N]);
boost::multi_array_ref<value_type,3> A_c1(A.data(),
boost::extents[M][N][L],cyclic_storage_order(1));
boost::multi_array_ref<value_type,3> A_c2(A.data(),
boost::extents[N][L][M],cyclic_storage_order(2));

Now all A, A_c1 and A_c2 use the same memory (and you can thus initialize A
through A_c1 or A_c2). If you need a "rotated 2D view", do as usual but
instead use A_c1 or A_c2.

I hope this answers your question.

Sincerely,

Pierre-André Noël

On Sun, May 22, 2011 at 1:34 PM, petros <pmamales_at_[hidden]> wrote:

> Hi Pierre-Andre,
> Thank you very much.
> Yes this helps immensely for the right hand-side of the derived system (say
> Ax = b).
> But for the creation of the matrix A (which incorporates boundary
> conditions and stencil calcs)
> a view with similar properties would still be needed.
> Also, can the starting point be a fortran storage order?
> Thank you again,
> Petros
>
>
> *From:* Pierre-Andre Noel <noel.pierre.andre_at_[hidden]>
> *Sent:* Sunday, May 22, 2011 12:27 PM
> *To:* boost-users_at_[hidden]
> *Subject:* Re: [Boost-users] multi-array and pdes
>
> I forgot a detail: once you got your "cyclic_storage_order", you should
> make a normal multi_array as usual then access it through a multi_array_ref
> that uses "cyclic_storage_order".
>
> On Sun, May 22, 2011 at 12:17 PM, Pierre-Andre Noel <
> noel.pierre.andre_at_[hidden]> wrote:
>
>> Hello Petros,
>>
>> I think that what you are looking for is a different storage order.
>>
>> Take a look at "boost/multi_array/storage_order.hpp". 3 classes are
>> defined: general_storage_order, c_storage_order and fortran_storage_order.
>>
>> You need to make a "cyclic_storage_order" (or something like that) that
>> receives an integer. When receiving zero, it should behave like
>> c_storage_order. When receiving 1, everything should be permuted by 1 etc.
>> This new class should inherit from general_storage_order. Use
>> c_storage_order and fortran_storage_order as examples.
>>
>> Keep "ascending" true, only "ordering" has to be changed. A modulo should
>> do it.
>>
>> Hope it helps,
>>
>> Pierre-André Noël
>>
>>
>> On Sun, May 22, 2011 at 11:53 AM, petros <pmamales_at_[hidden]> wrote:
>>
>>> Hi Larry,
>>> apologies, for not being clear.
>>> Yes, MA is boost::multi_array. M, N, L are the dimensions
>>> (this is only a "logical" statement, rather than a proper code snippet).
>>> I think I have pretty much sorted out the calling practices wrt
>>> multi-aray and looking
>>> for if certain functionality exists.
>>> My problem amounts to having a view that would allow for the permutation
>>> (if not rotation) of axes.
>>> As I begun to explain, the operator splitting methods decompose a problem
>>> in N dimensions
>>> into N 1-dimensional problems.
>>> The problem itself is stated, though, in a certain reference system (this
>>> means that the discretized
>>> operators (stencils) and the boundary conditions are expressed in terms
>>> of these boundary conditions.
>>> However, the linear equation systems that are produced, are in
>>> tridiagonal form, only in one of these steps
>>> ( the first step of the 1-D problems ). Otherwise it produces a
>>> block-banded system of equations, that can
>>> be reduced back to the familiar tridiagonal ( conceptually), through axes
>>> permutation (or rotation).
>>> If one things in terms of the 2D problem analog, while conceptually it
>>> would amount to exchange the two axes,
>>> in matrix form, and because of the storage alignment it would involve a
>>> much bigger operation. Since, these
>>> operators/systems are created from the problem, it would be very nice to
>>> have this view functionality to exploit
>>> for keeping the storage of the operators in the desired form.
>>>
>>> I hope this is clearer now - don't mean to drag you into my problem.
>>> Thank you for your response,
>>> Petros
>>>
>>>
>>> -----Original Message----- From: Larry Evans
>>> Sent: Sunday, May 22, 2011 10:43 AM
>>> To: boost-users_at_[hidden]
>>> Subject: Re: [Boost-users] multi-array and pdes
>>>
>>>
>>> On 05/21/11 15:02, petros wrote:
>>> Hi Petros,
>>>
>>> [snip]
>>>
>>>> Suppose then that I have a MA( M, N, L ):
>>>>
>>>
>>> Please be more specific. I assume:
>>>
>>> MA means boost::multi_array
>>>
>>> however, I've no idea what M, N, and L are. Could you please
>>> explain further?
>>>
>>> -regards,
>>> Larry
>>>
>>>
>>> _______________________________________________
>>> Boost-users mailing list
>>> Boost-users_at_[hidden]
>>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>>> _______________________________________________
>>> Boost-users mailing list
>>> Boost-users_at_[hidden]
>>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>>>
>>
>>
>
> ------------------------------
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net