Bernstein basis polynomials: Difference between revisions

Content added Content deleted
(I thought better of including the side note.)
Tag: Manual revert
(Added more explanation of the type-safety design: why what C/Pascal/C++/etc. do is inadequate.)
Line 563: Line 563:


(* Some macros that are convenient for type-safe floating point
(* Some macros that are convenient for type-safe floating point
without actually knowing which floating-point it will be. These
without actually knowing which floating-point type it will
macros will work if, in the context where they appear, the
be. These macros will work if, in the context where they appear,
typechecker can infer which floating-point type is meant. *)
the typechecker can infer which floating-point type is meant. *)
macdef one_third = g0i2f 1 / g0i2f 3
macdef one_third = g0i2f 1 / g0i2f 3
macdef one_half = g0i2f 1 / g0i2f 2
macdef one_half = g0i2f 1 / g0i2f 2
Line 572: Line 572:
(* We will try to achieve the type-safety of distinguishing between
(* We will try to achieve the type-safety of distinguishing between
monomial and Bernstein bases at compile time, but without overhead
monomial and Bernstein bases at compile time, but without overhead
at runtime. *)
at runtime. (As much type-safety as we achieve here can be done in
many other languages simply by giving the types different names but
the same fields. But then you cannot easily have type-safe
subprograms that work on EITHER type. Perhaps you could do it with
a type hierarchy, but then you start getting runtime overhead.) *)
tkindef monoknd = "rosettacode_monomial_poly"
tkindef monoknd = "rosettacode_monomial_poly"
tkindef bernknd = "rosettacode_bernstein_poly"
tkindef bernknd = "rosettacode_bernstein_poly"