📄 calc.html
字号:
<HTML><HEAD><TITLE>Newmat09 - calculus</TITLE></HEAD> <BODY><H2>A calculus of matrix types</H2><A HREF="err_hand.html"> next</A> - <A HREF="err_hand.html"> skip</A> - <A HREF="design.html"> up</A> - <A HREF="index.html"> start</A><P>The program needs to be able to work out the class of the result of amatrix expression. This is to check that a conversion is legal or todetermine the class of an intermediate result. To assist with this, a classMatrixType is defined. Operators <TT>+</TT>, <TT>-</TT>, <TT>*</TT>,<TT>>=</TT> are defined to calculatethe types of the results of expressions or to check that conversions arelegal.<P>Early versions of <I>newmat</I> stored the types of the results of operations ina table. So, for example, if you multiplied an UpperTriangularMatrixby a LowerTriangularMatrix, <I>newmat</I> would look up the table and seethat the result was of type Matrix. With this approach the<A HREF="explode.html">exploding</A> numberof operations problem recurred although not as seriously as when codehad to be written for each pair of types. But there was always the suspicionthat somewhere, there was an error in one of those 9x9 tables, that would bevery hard to find. And the problem would get worse as additional matrix typesor operators were included.<P>The present version of <I>newmat</I> solves the problem by assigning<I>attributes</I> such as <I>diagonal</I> or <I>band</I> or<I>upper triangular</I> to each matrix type. Which attributes amatrix type has, is stored as bits in an integer. As an example,the DiagonalMatrix type has the bits corresponding to <I>diagonal</I>,<I>symmetric</I> and <I>band</I> equal to 1.By looking at theattributes of each of the operands of a binary operator, the programcan work out the attributes of the result of the operation withsimple bitwise operations.Hence it can deduce an appropriate type. The <I>symmetric</I> attribute is aminor problem because <I>symmetric</I> * <I>symmetric</I> does not yield<I>symmetric</I> unless both operands are <I>diagonal</I>. But otherwisevery simple code can be used to deduce the attributes of the result ofa binary operation.<P>Tables of the types resulting from the binary operators are output at thebeginning of the <A HREF="testing.html">test</A> program. <P><A HREF="err_hand.html"> next</A> - <A HREF="err_hand.html"> skip</A> - <A HREF="design.html"> up</A> - <A HREF="index.html"> start</A><P></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -