-- RealVec.mesa, an interface for dealing with vectors of real numbers -- Last Modified On 16-Dec-81 11:59:57 By Paul Rovner RealVec: DEFINITIONS = { Object: TYPE = RECORD[elements: SEQUENCE length: NAT OF REAL]; Handle: TYPE = REF Object; -- convenient constructors All: PROC[length: NAT, value: REAL _ 0.0] RETURNS[Handle]; IndexVec: PROC[length: NAT] RETURNS[Handle]; -- h[0] = 0, h[n] = n -- convenient composition and extraction operations SubVec: PROC[h: Handle, firstIndex, lastIndex: NAT] RETURNS[Handle]; ConCat: PROC[h1, h2: Handle] RETURNS[Handle]; SortOrder: PROC[h: Handle] RETURNS[perms: Handle]; -- perms.elements[i] is the index in h of the ith smallest element -- i.e. (h.elements[perms.elements[i]] <= h.elements[perms.elements[i+1]]) Permute: PROC[h: Handle, perms: Handle] RETURNS[Handle]; -- h.elements[FixI[perms.elements[i]]] is put into ans.elements[i] -- e.g., Permute[h, SortOrder[h]] produces a sorted version of h Smooth: PROC[h: Handle, nElements: NAT] RETURNS[Handle]; -- nElements <= h.length. -- Result has averaged values as per some reasonable algorithm -- element-by-element operations Add, Subtract, Multiply, Divide: PROC[h1, h2: Handle] RETURNS[Handle]; -- scalar element-by-element operations ScalarAdd, ScalarSubtract, ScalarMultiply, ScalarDivide: PROC[h: Handle, s: REAL] RETURNS[Handle]; Equal: PROC[h1, h2: Handle] RETURNS[BOOLEAN]; DotProduct: PROC[h1, h2: Handle] RETURNS[REAL]; -- SIGNALS LengthFault: ERROR[vec: Handle, expectedLength: NAT]; }.