Vector and Matrix Objects This chapter describes an interface to vector and matrix objects which are not represented by plain lists (of plain lists), cf. Chapters and .
Concepts and Rules for Vector and Matrix Objects <#Include Label="MatObj_Overview">
Categories of Vector and Matrix Objects Currently the following categories of vector and matrix objects are supported in &GAP;. More can be added as soon as there is need for them. <#Include Label="IsVectorObj"> <#Include Label="IsMatrixObj"> <#Include Label="IsMatrixOrMatrixObj"> <#Include Label="IsRowListMatrix">
Defining Attributes of Vector and Matrix Objects <#Include Label="BaseDomain"> <#Include Label="ConstructingFilter"> <#Include Label="CompatibleVectorFilter"> <#Include Label="Length_IsVectorObj"> <#Include Label="NumberRowsNumberColumns">
Constructing Vector and Matrix Objects <#Include Label="NewVector"> <#Include Label="Vector"> <#Include Label="VectorObj_ZeroVector"> <#Include Label="NewMatrix"> <#Include Label="MatObj_Matrix"> <#Include Label="MatObj_ZeroMatrix"> <#Include Label="MatObj_IdentityMatrix">
Operations for Base Domains of Vector and Matrix Objects <#Include Label="OneOfBaseDomain">
Operations for Vector and Matrix Objects <#Include Label="MatrixObjCompare"> <#Include Label="Unpack"> <#Include Label="ChangedBaseDomain"> <#Include Label="Randomize">
List Like Operations for Vector Objects The following operations that are defined for lists are useful also for vector objects. (More such operations can be added if this is appropriate.) <#Include Label="ElementAccessVectorObj"> <#Include Label="MatObj_PositionNonZero"> <#Include Label="MatObj_PositionLastNonZero"> <#Include Label="MatObj_ListOp">
Arithmetical Operations for Vector Objects <#Include Label="VectorObj_UnaryArithmetics"> <#Include Label="VectorObj_BinaryArithmetics"> <#Include Label="MatObj_AddVector"> <#Include Label="MatObj_MultVectorLeft">
Operations for Vector Objects <#Include Label="MatObj_ConcatenationOfVectors"> <#Include Label="MatObj_ExtractSubVector"> <#Include Label="CopySubVector"> <#Include Label="MatObj_WeightOfVector"> <#Include Label="MatObj_DistanceOfVectors">
Arithmetical Operations for Matrix Objects <#Include Label="MatrixObj_UnaryArithmetics"> <#Include Label="MatrixObj_BinaryArithmetics">
Operations for Matrix Objects <#Include Label="MatObj_MatElm"> <#Include Label="MatObj_SetMatElm"> <#Include Label="ExtractSubMatrix"> <#Include Label="MutableCopyMatrix"> <#Include Label="CopySubMatrix"> <#Include Label="CompatibleVector"> <#Include Label="RowsOfMatrix"> <#Include Label="MatObj_CompanionMatrix">
Operations for Row List Matrix Objects In general, matrix objects are not lists in the sense of , and they need not behave like lists, that is, they need not obey all the rules for lists that are stated in Chapter . There are situations where one wants to have matrix objects that can on the one hand benefit from &GAP;'s method selection, as is explained in Section , and do on the other hands support access to &GAP; objects that represent their rows (which are suitable vector objects). Matrix objects whose value implies support the operations described in this section.

One implementation of such matrices is given by the value , and any row of these matrices is a vector object in . Note that these objects do not lie in (and in particular not in ), thus we are allowed to define the above operations only restrictively, as follows.

Unbinding an entry in a row or unbinding a row in a matrix is allowed only in the last position, that is, the vector and matrix objects insist on being dense. All rows of a matrix must have the same length and the same base domain. <#Include Label="RowListMatObj_[]"> <#Include Label="RowListMatObj_[]_ASS"> <#Include Label="RowListMatObj_{}"> <#Include Label="RowListMatObj_{}_ASS"> <#Include Label="RowListMatObj_IsBound"> <#Include Label="RowListMatObj_Unbind"> <#Include Label="RowListMatObj_Add"> <#Include Label="RowListMatObj_Remove"> <#Include Label="RowListMatObj_Append"> <#Include Label="RowListMatObj_ShallowCopy"> <#Include Label="RowListMatObj_ListOp">
Basic operations for row/column reductions <#Include Label="MultMatrixRow"> <#Include Label="MultMatrixRowRight"> <#Include Label="MultMatrixColumn"> <#Include Label="MultMatrixColumnLeft"> <#Include Label="AddMatrixRows"> <#Include Label="AddMatrixRowsRight"> <#Include Label="AddMatrixColumns"> <#Include Label="AddMatrixColumnsLeft"> <#Include Label="SwapMatrixRows"> <#Include Label="SwapMatrixColumns">
Implementing New Vector and Matrix Objects Types The first step in the design of a new type of vector or matrix objects is to create a new filter that serves as the of the new objects, see the sections and for an overview of such filters that are already available.

Here we list those operations for vector and matrix objects for which no default methods can be installed. When one implements a new type of vector or matrix objects then one has to install specific methods at least for these operations, in order to make the objects behave as described in this chapter. It is advisable to install specific methods also for other operations, for performance reasons. The installations of default methods can be found in the file lib/matobj.gi of the &GAP; distribution. There one can check for which operations it makes sense to overload them for the new type of vector or matrix objects. Note that the specific methods must be installed with whenever the default method is installed with this function.

Vector objects , , , (with consistency checks if the global option check is not set to false), (see ), , (with consistency checks if the global option check is not set to false, install the method with ).

Matrix objects , , , , (with consistency checks if the global option check is not set to false), (see ), , , (with consistency checks if the global option check is not set to false, install the method with ).

Methods for and must check their arguments for consistency (do the given filter and base domain fit together, are the entries compatible with the given base domain, is the number of matrix entries a multiple of the given number of columns) except if the global option check is set to false. (See Chapter for information about global options.) The same holds for methods for operations that modify mutable vector or matrix objects, such as , , , , and for those methods of and that do not delegate to and , respectively.
Available Representations of Vector Objects The following filters define vector objects for which the the functionality described in this chapter is supported. <#Include Label="IsGF2VectorRep"> <#Include Label="Is8BitVectorRep"> <#Include Label="IsPlistVectorRep"> <#Include Label="IsZmodnZVectorRep">
Available Representations of Matrix Objects The following filters define matrix objects for which the the functionality described in this chapter is supported. <#Include Label="IsGF2MatrixRep"> <#Include Label="Is8BitMatrixRep"> <#Include Label="IsPlistMatrixRep"> <#Include Label="IsZmodnZMatrixRep">