Thread Links | Date Links | ||||
---|---|---|---|---|---|
Thread Prev | Thread Next | Thread Index | Date Prev | Date Next | Date Index |
The attached pages from Sun/Oracle's documentation for its Fortran implementation of interval data types might be informative.
See below. On 10/6/13 4:50 PM, Richard Fateman wrote:
The Sun/Oracle Fortran implementation supports both more than 2 arguments and array arguments.On 10/6/2013 1:03 PM, Michel Hack wrote:I think it is a mistake to require min or max of k arguments except for k=2.So for each "k", it is necessary 2^(k+1) variants. This is a combinatoric explosure. How can I bind this in C ?Input arguments can be widened to the widest-supported type. This avoids combinatorial explosion; you only need one function per target type. Several functions, including min/max, don't involve rounding, so you can generate a wide result and round it once to the target type.Functions like min/max are often expressed as macros in C, again avoiding type issues. Indeed, macros using the compile-time built-in typeof() canprovide the appearance of polymorphism. Michel. ---Sent: 2013-10-06 20:09:50 UTCPresumably the macro expansion that Michel suggests requires only max2(a,b), and max(a,b,c,d) would be expanded to max2(a,max2(b,max2(c,d))) etc.Some languages will support the k-ary version, but why should the standardrequire languages to do so? Perhaps thereby excluding FORTRANs that may still be in use.
The Sun/Oracle Fortran implementation uses widest need expression evaluation to fully support mixed interval type expressions, wherein every non-interval is promoted to a containing interval with the highest kind-type-parameter-value (ktpv) prior to interval evaluation of the given expression.If it is used in the form x := max(a,b) and the types of a,b,x are all different,do we (in effect) convert them all to the type of x to do the comparison? Does it even matter unless there is overflow in conversion?
Containment sets resolve any ambiguity about the mathematical definition of what must be contained in the interval evaluation of any expression or function.I would expect that if a,b are intervals, thatthe return value of max(a,b) is either the memory location where a is stored or where b is stored. Not another location where there is a conversion of a or bto the type of x. But frankly I don't know what is intended here.
See the definition of a containment set and the assignment statement operator.Equality has an issue too.If we compute max(A,B) where A and B are structures which are intervals, and they are of the same type and have equal components, and max returns a pointer to one of them, which one? I suspect this can affect the efficiency of (say)an implementation of heapsort. Also, if they are equal because they are stored in the same location, what does max say, even if A=B=NAI.
Unnecessarily limited. However, I strongly support a permissive interval standard in which the *only* requirement is to not violate the containment constraint. Thus, any language implementation should be permitted to implement the interval syntax and semantics of the interval evaluation of any standard function in any way, provided only that containment not be violated.So there are two items in this message: 1. How about just max_of_two_arguments(x1,x2) etc for min
This is so elegant and so simple. :)
Any interval enclosure of the given function's containment set. Speed and width are quality of implementation features.2. What really is returned?
Apologies if I am missing something that is already resolved.
On the contrary, you raise important and fundamental questions. Cheers, Bill
RJF
Attachment:
pg 50 of “Fortran95_Prog_Ref.pdf”.pdf
Description: Adobe PDF document
Attachment:
pgs 127-128 of “Fortran95_Prog_Ref.pdf”.pdf
Description: Adobe PDF document
Attachment:
pgs 26-28 of “Fortran95_Prog_Ref.pdf”.pdf
Description: Adobe PDF document
Attachment:
pgs 39-42 of “Fortran95_Prog_Ref.pdf”.pdf
Description: Adobe PDF document