-
Notifications
You must be signed in to change notification settings - Fork 1
/
infinite.ml
57 lines (42 loc) · 1.53 KB
/
infinite.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
open Hilbertspace;;
open Gk;;
module Real = Floatreal.Real
module FunctionHilbert : HilbertSpace with type vect = (float -> float) with type ct = Real.t = struct
let a = -1.0
let b = 1.0
let tol = 1e-6
let rec poly i x = if i==0 then (1.0) else ( x *. (poly (i-1) x))
type vect = (float -> float)
type ct = Real.t
let nullvector = fun x -> 0.0
let basis i = poly i
let scalarmul s f = fun x -> s *. (f x)
let add f1 f2 = fun x -> (f1 x) +. (f2 x)
let innerprod f1 f2 =
let f = fun x -> (f1 x) *. (f2 x) in
Quad.gkint f a b tol
let norm p = (Real.sqrt (innerprod p p))
let to_string p = "opaque"
end;;
module CompressedFunctionHilbert : HilbertSpace with type vect = (float -> float) with type ct = Real.t = struct
let a = -1.0
let b = 1.0
let tol = 1e-6
let rec poly i x = if i==0 then (1.0) else ( x *. (poly (i-1) x))
type vect = (float -> float)
type ct = Real.t
let nullvector = fun x -> 0.0
let basis i = poly i
let scalarmul s f = fun x -> s *. (f x)
let add f1 f2 = fun x -> (f1 x) +. (f2 x)
let innerprod f1 f2 =
let f = fun x -> (f1 x) *. (f2 x) in
Quad.gkint f a b tol
let norm p = (Real.sqrt (innerprod p p))
let to_string p = "opaque"
end;;
module MyOp = MakeOperatorSpace (Real) (FunctionHilbert) (FunctionHilbert)
module MySqOp = MakeSquareOperatorSpace (Real) (FunctionHilbert)
module MyOrth = MakeOrthogonalizable (Real) (FunctionHilbert)
let a f = fun x -> (sin x) *. (f x)
let k f = fun x -> Quad.gkint (fun y->(cos (y-.x)) *. (f y)) (-1.0) (1.0) (1e-6)