
vector Specification SheetComputer Algebra Kit (c) 1993,00 by Comp.Alg.Objects. All Rights Reserved.
VectorInherits from: CAObjectMaturity Index: Relatively mature
Class DescriptionA vector consists of a number of scalars that can be arbitrary Computer Algebra Kit objects, but they currently have to be either floatingpoint or elements of a field (see inField) or elements of an integral domain (see inIntegralDomain).There are methods to access, insert and remove scalars. It's also possible to place or replace a scalar directly at a given index. See the documentation on eachScalar to access the scalar at a given index. Note: Vector objects are meant for computational tasks. They are no substitute for List or Collection objects, that are better suited for the purpose of storing objects.
Method typesCreationIdentityInsertion ScalarsRemoving ScalarsPlacing and ReplacingAccessing ScalarsAdditionScalar MultiplicationMultiplicationPrintingMethodscollection:+collection:aCltnCreates a vector containing references to the scalars from aCltn. The collection must not be empty.
scalarZero:numScalars:+scalarZero:aScalarZeronumScalars:(int)numScalarsCreates a new vector with numScalars zero scalars.
copycopyReturns a new vector.
deepCopydeepCopyReturns a new vector. Sends deepCopy messages to the scalars in the vector.
scalarZeroscalarZeroReturns the zero scalar element.
numScalars (int)numScalarsReturns the number of scalar objects in the vector. Returns 0 if the vector is empty. The first scalar in the vector is at index 0, the last scalar at numScalars minus one.
insertScalar:insertScalar:aScalarInserts aScalar as first entry and returns self. The object aScalar belongs to the vector after insertion, and is not necessarily copied. To insert a scalar, the reference count of the vector should be equal to one.
insertScalar:at:insertScalar:aScalarat:(int)iInserts aScalar as ith entry and returns self. The object aScalar belongs to the vector after insertion, and is not necessarily copied. If i is equal to zero, this method is identical to insertScalar:. If i is equal to numScalars, this method inserts the scalar as last element.
removeScalarremoveScalarRemoves (and returns) the first scalar in the vector (the scalar at index 0). Returns nil if there were no more elements left. This can be used in the following way :
To remove a scalar, the reference count of the vector should be equal to one.while (c = [vector removeScalar]) { /* do something with c */ }
removeScalarAt:removeScalarAt:(int)iRemoves and returns the ith scalar in the vector. If i is zero, this method is identical to removeScalar. Unlike removeScalar, which returns nil if there are no more scalars in the vector, this method generates an error message if you attempt to remove a scalar at an illegal index.
placeScalar:at:placeScalar:aScalarat:(int)iFrees the scalar at position i and replaces it by the scalar object aScalar. Returns self. The scalar aScalar belongs to the receiving vector object; it is not necessarily copied. This is similar to List's addObject: method. It is an error to use an illegal index i or to attempt to set a scalar in a vector whose reference count is not equal to one.
replaceScalarAt:with:replaceScalarAt:(int)iwith:aScalarSimilar to placeScalar:at: but returns the scalar at position i after replacing it by aScalar. It is an error to use an illegal index i or to attempt to replace a scalar in a vector whose reference count is not equal to one.
asCollectionasCollectionReturns a new collection containing new references to the scalars in the vector.
asNumericalasNumericalReturns a new vector, whose scalars are the numerical value of the scalars of the original vector.
asModp:asModp:(unsigned short)pReturns a new vector, whose scalars are the value of the scalars of the original vector mod p.
onCommonDenominator:onCommonDenominator:(id *)denominatorPuts a vector with fractional scalars on a common denominator. Returns a new vector with integral scalars, and, by reference, the common denominator of the scalars in the vector.
eachScalareachScalarReturns a new sequence object that gives access to the scalars of the vector.
floatValueAt: (float)floatValueAt:(int)iReturns the floatValue of the scalar at the ith position.
intValueAt: (int)intValueAt:(int)iReturns the intValue of the scalar at the ith position.
zerozeroReturns a vector of the same dimension as the object that receives the message, but all filled with zero scalars.
addScalar:at:addScalar:sat:(int)iReturns a new vector. Adds s to the scalar at position i, and replaces the scalar by the sum. i must be between 0 and the number of scalars in the vector. This method is not an insertion method. See also: insertScalar:at:, replaceScalar:at:
subtractScalar:at:subtractScalar:sat:(int)iReturns a new vector. Subtracts s from the scalar at position i. i must be between 0 and the number of scalars in the vector. This method is not an insertion method.
dotSquaredotSquareReturns a new scalar product, the dot product of the vector by itself, defined as the sum of squares of the scalars in the vector.
dotMultiply:dotMultiply:aVectorReturns a new scalar product, the dot product of the vector self by aVector, defined as the sum of the products of the scalars in the vectors.
multiplyLeftMatrix:multiplyLeftMatrix:aMatrixReturns a new vector, the product of aMatrix by the column vector self.
printOn:printOn:(IOD)aFilePrints, between braces, a comma separated list of the scalars (by sending printOn: messages to the scalars).
