QuoteOriginally posted by: CuchulainnQuoteFinally, is "Real" a good name that we want to have -- Alan mentioned complex coefficients and multi-precision features of Mathematica, in general we only have different kinds of floating-point-numbers and integers available out of the box. Coefficients can belong to any Ring , including complex, rational and Interval (uncertain coefficients) yes?Yes, that's what I was generally thinking about!Although a few caveats apply that we might think about/brainstorm, see below.QuoteOriginally posted by: CuchulainnIn C++ a templated infinity could be used and it would be in line with the underlying type (e.g. float, double). Polter, is this a good idea?numeric lmits Yeah, this might also come in handy:Floating-Point Classification: Infinities and NaNsQuoteOriginally posted by: CuchulainnQuoteThe Ring is also a good idea.'Ring' could be a concept describing the interface +, *, for mathematical rings (including 0<T> and 1<T> if you get my drift)?? Then real classes implement the concept.outrun & Cuchulainn -- see also:Conceptual Requirements for Real Number TypesConceptual Archetypes for Reals and DistributionsNow, regarding the caveats and ideas.First, the caveats -- when thinking about a type models a concept, there are further distictions to be made, which is esp. relevant when we're talking about floating-point-types and, say, RealType concept -- two further levels of distiction are partial models (this already kicks for integers) and approximate models.The below are points from "Notes on Programming" by Alexander Stepanov, Lecture 10. Generic algorithms:
http://www.stepanovpapers.com/notes.pdfoutrun & Cuchulainn: he introduces the relationships between concepts and the relevant algebraic structures, like Monoids, Semigroups, etc. -- I think his comments convention might be quite nice there, so I included a few code snippets (there's plenty more in the Notes), what do you think?Quote"When we dealt with max, min and other order selection operations we observed that they are defined on types that satisfy certain requirements: namely, they provide a strict weak ordering or, in cases when we use operator<, a strict total ordering. A collection of types that satisfy a common set of requirements is called a concept. A common example of a concept is the concept of Integral: a collection of all integer types in C. A type in the collection associated with a particular concept is said to model this concept or, using a noun instead of a verb, is a model of this concept. int is a model of Integral. An algorithm that is defined on all the types in a concept is called a generic algorithm."Quote"The third objection to the code is that, strictly speaking, no type can model a totally ordered group. (Or, being precise, no type with a non-zero element can be such a model.) Indeed, from the axioms we can derive that in such a group there are no elements of finite order and therefore the group is infinite. As we all know, even with memory being cheap, computers cannot hold infinitely many different values. A type such as int is not strictly speaking a group under addition, since addition is not defined when we add two values whose sum is greater than MAX_INT. Moreover, C does not seem to guarantee that -MIN_INT is defined. There could be more negative numbers than positive numbers and that will prevent our abs from being a total function. We need to drop the requirement that the model implements all the operations defined in the concepts as total functions. Operations can be implemented as partial functions, and the axioms have to hold only when all the operations are defined. Our models are partial models"Quote"Sometimes even using a partial model is not good enough. Sometimes even when the basic operations are defined, the axioms do not hold. In particular, when we deal with doubles all the equational axioms are suspect. Even such a basic law as associativity of addition does not hold. We need to develop a notion of an approximate model but that clearly is outside of the scope of this course, since it belongs to a course on Generic Numerical Methods which I plan to teach in the year 2016."