abs_vec.sa


Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
 
------------------------->  GNU Sather - sourcefile  <-------------------------
-- Copyright (C) 2000 by K Hopper, University of Waikato, New Zealand        --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute  and/or modify it under the terms of the GNU Library General --
-- Public  License (LGPL)  as published  by the  Free  Software  Foundation; --
-- either version 2 of the license, or (at your option) any later version.   --
-- This  library  is distributed  in the  hope that it will  be  useful, but --
-- WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See Doc/LGPL for more details.       --
-- The license text is also available from:  Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                     --
-------------->  Please email comments to <bug-sather@gnu.org>  <--------------


abstract class $VEC{ET < $NFE{ET}, VT < $VEC{ET,VT}}

abstract class $VEC{ET < $NFE{ET}, VT < $VEC{ET,VT}} is -- This abstract class is the specification of the general vector class. -- -- This is mostly straightforward except for a minor complexity in relation to complex vectors. These still need to have lengths which return real numbers, and not CPX. However, the length in a complex vector has to be the same as the type of the components of the complex, since this fact is used in some of the functions. -- -- NOTE This class does not need to know about its companion, matrix, class. The converse is not true so that all matrix-vector operations are in the corresponding matrix class, although the matrix type does know about the vector class. -- Version 1.2 Aug 97. Copyright K Hopper, U of Waikato -- Development History -- ------------------- -- Date Who By Detail -- ---- ------ ------ -- 5 May 96 mbk Original -- 18 Jul 96 ds Modified for 1.1 -- 25 Aug 97 kh Modified for cardinals and portability. dim : CARD ; -- number of dimensions. create( sz : CARD ) : VT ; -- This creation routine produces a new vector of size dimensions. create( arg : VT ) : VT ; -- This creation routine produces a new empty vector of the size of arg. array : ARRAY{ET} ; -- This routine produces an array of the same dimensionality as self -- with projections of this vector upon each axis. copy : VT ; -- This routine produces a new vector which is a copy of self. inplace_contents( arg : VT ) ; -- This routine sets the array portion of self to have the values of -- the array portion of arg. inplace_contents_subspace( destbeg, cnt, srcbeg : CARD, arg : VT ) ; -- This routine assigns cnt components starting with that indicated by -- srcbeg to elements of self starting at destbeg. inplace_contents_from_function( function : ROUT{CARD} : ET ) ; -- This routine sets the elements of self to have the values given by -- applying function to each index in turn. inplace_elements( arg : ET ) ; -- This routine sets all elements of self to have the given value. inplace_unit_vector( index : CARD ) ; -- This routine sets the indicated component of self to be the unit -- vector. same_size( arg : VT ) : BOOL ; -- This routine returns true if and only if arg has the same size as -- self. False is returned if either or both are void. is_eq( other : VT ) : BOOL ; -- This orutine returns true if and only if self and other have the same -- value. aget( index : CARD ) : ET ; -- This orutine returns the value of the indicated element. aset( index : CARD, val : ET ) ; -- This orutine sets the projection of the vector in the indicated -- direction. plus( arg : VT ) : VT ; -- This routine returns a new vector whose elements are the sum of the -- corresponding elements of self and arg. plus_arg( arg : VT ) : VT ; -- This routine is a synonym for plus above. minus( arg : VT ) : VT ; -- This routine returns a new vector which is the result of subtracting -- arg from self. minus_arg( arg : VT ) : VT ; -- This routine is a synonym for minus above. inplace_plus_arg( arg : VT ) ; -- This routine sets the elements of self to be the result of adding -- the corrsponding elements of arg to them. inplace_minus_arg( arg : VT ) ; -- This routine sets the elements of self to be the result of -- subtracting the corresponding elements of arg from them. inplace_arg_plus_arg( arg1, arg2 : VT ) ; -- This routine sets the elements of self to be the values given by -- adding the corresponding elements of arg1 and arg2. inplace_arg_minus_arg( arg1, arg2 : VT ) ; -- This routine sets the elements of self to have the value given by -- subtracting the corresponding element of arg2 from that of arg2. plus_scaled_arg( scale : ET, arg : VT ) : VT ; -- This outine returns a new vector whose elements are the result of -- adding together the corresponding element of self and the scaled element -- of arg. inplace_plus_scaled_arg( scale : ET, arg : VT ) ; -- This routine sets the elements of self to be the sum of their -- original value and the scaled value of the corresponding element of arg. inplace_arg_plus_scaled_arg( arg1 : VT, scale : ET, arg2 : VT ) ; -- This routine sets the elements of self to be the sum of the -- corresponding element of arg1 and the scaled value of that of arg2. times( scale : ET ) : VT ; -- This routine creates a new vector all of the elements of which are -- the values of self scaled as indicated. scaled_by( scale : ET ) : VT ; -- This routine is a synonym for times. inplace_scaled_by( scale : ET ) ; -- This routine scales all of te elements of self by the given factor. inplace_swapped( arg : VT ) ; -- This routine swaps the contents of self with that of arg (providing -- they are the same size!). str : STR ; -- This routine returns a text string representation of self. end ; -- $VEC{ET,VT}

abstract class $VEC{ET < $NFE{ET}, VT<$VEC{ET,VT}, LTP<$REAL{LTP}} <

abstract class $VEC{ET < $NFE{ET}, VT<$VEC{ET,VT}, LTP<$REAL{LTP}} < $VEC{ET,VT} is -- This abstract class is a full specification which is parameterised -- over the type of vector length in order to deal correctly with length, -- magnitudes, etc -- Version 1.2 Aug 97. Copyright K Hopper, U of Waikato -- Development History -- ------------------- -- Date Who By Detail -- ---- ------ ------ -- 5 May 96 mbk Original -- 18 Jul 96 ds Modified for 1.1 -- 25 Aug 97 kh Modified for cardinals and portability. dot( arg : VT ) : ET ; -- This routine returns the dot product of self and arg. cosine_angle_with( arg : VT ) : LTP ; -- This outine returns the cosine of the angle between self and arg in radians. This is usually faster than the routine above. length_squared : LTP ; -- This routine returns the squared length of self. This is the -- conventional Euclidean metric. length : LTP ; -- This routine returns the length of self -- the conventional metric. distance_to_squared( arg : VT ) : LTP ; -- This routine returns the square of the distance between self and arg. distance_to( arg : VT ) : LTP ; -- This routine returns the distance between self and arg. bounded_distance_to_squared( arg : VT, sbnd : LTP ) : LTP ; -- This routine returns the distance between arg and self provided that it is less than or equal to sbnd. Otherwise nil is returned. inplace_normalized ; -- This routine scales self to have unit length! end ; -- $VEC{ET,VT,LTP}