- Hi

I am looking for an implementation of a triangular matrix (upper or lower).

This matrix is not supposed to be located inside an array2 but inside a

"real triangular" structure.

This will be used in order to store distances between a set of points.

An associated library capable of building would be a plus but is not

absolutely required (I already have something working).

Thanks in advance for your time.

Regards.

Johan Mazel

[Non-text portions of this message have been removed] > This matrix is not supposed to be located inside an array2 but inside a

In OCaml, the ('a array array) type does not mandate all subarrays to

> "real triangular" structure.

be of the same length. You can create "triangular structures" of that

type:

# [| [| 1 |]; [| 2; 3 |]; [| 4; 5; 6 |] |];;

- : int array array = [|[|1|]; [|2; 3|]; [|4; 5; 6|]|]

I'm not exactly sure what you mean by "real triangular", but if you

are just looking for a way to avoid the memory consumption overhead of

having half of a matrix unused, this may be a satisfying solution.

On Wed, Jul 13, 2011 at 4:36 PM, Johan Mazel <johan.mazel@...> wrote:

> Hi

> I am looking for an implementation of a triangular matrix (upper or lower).

> This matrix is not supposed to be located inside an array2 but inside a

> "real triangular" structure.

> This will be used in order to store distances between a set of points.

> An associated library capable of building would be a plus but is not

> absolutely required (I already have something working).

> Thanks in advance for your time.

> Regards.

> Johan Mazel

>

>

> [Non-text portions of this message have been removed]

>

>

>

> ------------------------------------

>

> Archives up to December 31, 2010 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners

> The archives of the very official ocaml list (the seniors' one) can be found at http://caml.inria.fr

> Attachments are banned and you're asked to be polite, avoid flames etc.Yahoo! Groups Links

>

>

>

>- Well, this exactly how I would have done the job. :)

Except that I may have replaced the array of array by an array of array1

since the ocaml documentation says that array1 are supposed to faster in

access and safer than array.

My email what just sent in the hope that, maybe, somebody would have done

this job before.

Regards.

Johan

2011/7/13 Gabriel Scherer <gabriel.scherer@...>

> **

[Non-text portions of this message have been removed]

>

>

> > This matrix is not supposed to be located inside an array2 but inside a

> > "real triangular" structure.

>

> In OCaml, the ('a array array) type does not mandate all subarrays to

> be of the same length. You can create "triangular structures" of that

> type:

> # [| [| 1 |]; [| 2; 3 |]; [| 4; 5; 6 |] |];;

> - : int array array = [|[|1|]; [|2; 3|]; [|4; 5; 6|]|]

>

> I'm not exactly sure what you mean by "real triangular", but if you

> are just looking for a way to avoid the memory consumption overhead of

> having half of a matrix unused, this may be a satisfying solution.

>

>

> On Wed, Jul 13, 2011 at 4:36 PM, Johan Mazel <johan.mazel@...>

> wrote:

> > Hi

> > I am looking for an implementation of a triangular matrix (upper or

> lower).

> > This matrix is not supposed to be located inside an array2 but inside a

> > "real triangular" structure.

> > This will be used in order to store distances between a set of points.

> > An associated library capable of building would be a plus but is not

> > absolutely required (I already have something working).

> > Thanks in advance for your time.

> > Regards.

> > Johan Mazel

> >

> >

> > [Non-text portions of this message have been removed]

> >

> >

> >

> > ------------------------------------

>

> >

> > Archives up to December 31, 2010 are also downloadable at

> http://www.connettivo.net/cntprojects/ocaml_beginners

> > The archives of the very official ocaml list (the seniors' one) can be

> found at http://caml.inria.fr

> > Attachments are banned and you're asked to be polite, avoid flames

> etc.Yahoo! Groups Links

> >

> >

> >

> >

>

>

>

- Personally, I would look if the mathematical function you are looking

for is in the GNU Scientific Library, then I would

build a wrapper for the function I need to call and give it a

Bigarray to work on.

Also, I think the idea of storing an N dimensional array

into a 1 dimension one is a good practice, as suggested by Christophe.

On 07/14/2011 12:42 AM, Christophe TROESTLER wrote:

> On Wed, 13 Jul 2011 16:36:45 +0200, Johan Mazel wrote:

> >

> > I am looking for an implementation of a triangular matrix (upper or

> lower).

> > This matrix is not supposed to be located inside an array2 but inside a

> > "real triangular" structure.

> > This will be used in order to store distances between a set of points.

> > An associated library capable of building would be a plus but is not

> > absolutely required (I already have something working).

>

> To store A(i,j) with 0 ≤ i < j < n, you can use the so called packed

> storage:

>

> A(i,j) = array1.(i*(n-1) - (i*(i+1))/2 + j - 1)

>

> where "array1" has size n(n-1)/2 [check the indices, I did that quickly].

>

> - Hi

Thanks a lot for the hint to use packed storage.

I implemented it inside a simple module attached to this mail.

Regards

Johan

2011/7/14 Francois Berenger <berenger@...>

> **

[Non-text portions of this message have been removed]

>

>

> Personally, I would look if the mathematical function you are looking

> for is in the GNU Scientific Library, then I would

> build a wrapper for the function I need to call and give it a

> Bigarray to work on.

>

> Also, I think the idea of storing an N dimensional array

> into a 1 dimension one is a good practice, as suggested by Christophe.

>

>

> On 07/14/2011 12:42 AM, Christophe TROESTLER wrote:

> > On Wed, 13 Jul 2011 16:36:45 +0200, Johan Mazel wrote:

> > >

> > > I am looking for an implementation of a triangular matrix (upper or

> > lower).

> > > This matrix is not supposed to be located inside an array2 but inside a

> > > "real triangular" structure.

> > > This will be used in order to store distances between a set of points.

> > > An associated library capable of building would be a plus but is not

> > > absolutely required (I already have something working).

> >

> > To store A(i,j) with 0 ≤ i < j < n, you can use the so called packed

> > storage:

> >

> > A(i,j) = array1.(i*(n-1) - (i*(i+1))/2 + j - 1)

> >

> > where "array1" has size n(n-1)/2 [check the indices, I did that quickly].

> >

> >

>

>

>