Re: Dot product in computer languages
Richard,
On 04/27/2015 07:13 PM, Richard Fateman wrote:
.
.
.
"Experience has shown that computing the dot product by function calls
leads
to clumsy and awkward programming. "
I don't understand this. If A,B are vectors (or pointers to vectors)
and C is a storage array for a (complete?) number (or pointer to it),
then
C:=dotproduct(A,B)
is probably supportable in some languages. Maybe
The Fortran standard specifies dot_product as an intrinsic
function (available with all standard-conforming Fortran compilers).
The syntax is:
SCALAR_VALUE = DOT PRODUCT (VECTOR A, VECTOR B)
C:= A dotproduct B.
That can also be done in Fortran using operator overloading.
There is no accuracy requirement in the Fortran standard for
operations and functions. However, the IEEE intrinsic module in
Fortran 2003 (available with all standard-conforming Fortran
compilers) specifies IEEE 754 arithmetic. Furthermore, it is
not uncommon for the compiler to translate the source to code
for the basic operations that uses IEEE 754 arithmetic.
but even a FORTRAN call dotproduct(A,B,C)
is not so bad.
The user need not write such a subroutine, since the
dot product is available as an intrinsic function.
If the user has a module providing an exact dot product,
the user may define that data type and overload
the intrinsic function.
Baker
--
---------------------------------------------------------------
Ralph Baker Kearfott, rbk@xxxxxxxxxxxxx (337) 482-5346 (fax)
(337) 482-5270 (work) (337) 993-1827 (home)
URL: http://interval.louisiana.edu/kearfott.html
Department of Mathematics, University of Louisiana at Lafayette
(Room 217 Maxim D. Doucet Hall, 1403 Johnston Street)
Box 4-1010, Lafayette, LA 70504-1010, USA
---------------------------------------------------------------