From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id CAA22864; Tue, 12 Aug 2003 02:02:43 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA16177 for ; Tue, 12 Aug 2003 02:02:42 +0200 (MET DST) Received: from poincare (ppp-62-235-152-145.tiscali.be [62.235.152.145]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h7C02eT29193 for ; Tue, 12 Aug 2003 02:02:41 +0200 (MET DST) Received: from poincare ([127.0.0.1] helo=localhost ident=trch) by poincare with esmtp (Exim 3.36 #1 (Debian)) id 19mMWG-0001mc-00; Tue, 12 Aug 2003 01:56:08 +0200 Date: Tue, 12 Aug 2003 01:56:08 +0200 (CEST) Message-Id: <20030812.015608.19060385.del-con@tiscali.be> To: "O'Caml Mailing List" Subject: [Caml-list] Array1.fold_left From: Christophe TROESTLER Organization: None X-Spook: clandestine Rule Psix dictionary HAMASMOIS assassinate supercomputer ASO CID Ron Brown broadside X-Mailer-URL: http://www.mew.org/ X-Operating-System: GNU/Linux (http://www.linux.org/) X-Blessing: Om Ah Hum Vajra Guru Pema Siddhi Hum X-Mailer: Mew version 3.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; troestler:01 tiscali:99 elt:01 superfluous:01 permuting:01 chris:01 bigarray:01 christophe:01 primitives:01 writes:01 float:02 obj:03 library:03 suppose:03 fortran:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi all, For the following discussion, one assumes to be in the scope of an [open Bigarray]. Suppose for example I want to compute the maximum of [a] of type (float, float64_elt, 'a) Array1.t. I can imagine the following code: let array1_max a = let m = ref (-. infinity) in if Array1.layout a = (Obj.magic c_layout : 'a Bigarray.layout) then for i = 0 to Array1.dim a - 1 do if !m < a.{i} then m := a.{i} done else (* fortran layout *) for i = 1 to Array1.dim a do if !m < a.{i} then m := a.{i} done; !m Actually, the test on the layout is superfluous since all elements of the array are accessed. But there is no way to get rid of it unless one writes a C function. Wouldn't be nicer (and more efficient?) to have primitives like Array1.fold_left ? Is there a reason such functions are not part of the standard library? Another interesting functions may be: c_to_fortran : ('a, 'b, c_layout) Array1.t -> ('a, 'b, fortran_layout) Array1.t fortran_to_c : ('a, 'b, fortran_layout) Array1.t -> ('a, 'b, c_layout) Array1.t (permuting the dimension). Maybe other people working with numerical code could speak up -- I guess I am not the only one with this kind of needs, am I. Cheers, ChriS ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners