46 lines
1.7 KiB
Plaintext
46 lines
1.7 KiB
Plaintext
(***********************************************************************)
|
|
(* *)
|
|
(* Objective Caml *)
|
|
(* *)
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
(* *)
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
|
(* under the terms of the Q Public License version 1.0. *)
|
|
(* *)
|
|
(***********************************************************************)
|
|
|
|
(* $Id$ *)
|
|
|
|
("res_square": skip 8)
|
|
("h": skip 8)
|
|
("x": skip 8)
|
|
("s": skip 8)
|
|
("res_integr": skip 8)
|
|
|
|
(function "square" (x: addr)
|
|
(let r "res_square"
|
|
(store float r ( *f (load float x) (load float x)))
|
|
r))
|
|
|
|
(function "integr" (f: addr low: addr high: addr n: int)
|
|
(let (h "h" x "x" s "s" i n)
|
|
(store float h (/f (-f (load float high) (load float low)) (floatofint n)))
|
|
(store float x (load float low))
|
|
(store float s 0.0)
|
|
(while (> i 0)
|
|
(store float s (+f (load float s) (load float (app f x addr))))
|
|
(store float x (+f (load float x) (load float h)))
|
|
(assign i (- i 1)))
|
|
(store float "res_integr" ( *f (load float s) (load float h)))
|
|
"res_integr"))
|
|
|
|
("low": skip 8)
|
|
("hi": skip 8)
|
|
|
|
(function "test" (n: int)
|
|
(store float "low" 0.0)
|
|
(store float "hi" 1.0)
|
|
(load float (app "integr" "square" "low" "hi" n addr)))
|
|
|