⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unspec.html

📁 矩阵算法库newmat10.tar.gz的帮助文件
💻 HTML
字号:
<HTML><HEAD><TITLE>Newmat09 - unspecified type</TITLE></HEAD><BODY><H2>Unspecified type</H2><A HREF="cholesky.html">  next</A> - <A HREF="cholesky.html">  skip</A> - <A HREF="refer.html">  up</A> - <A HREF="index.html">  start</A><P>Skip this section on your first reading.<P>If you want to work with a matrix of unknown type, say in a function. Youcan construct a matrix of type <TT>GenericMatrix</TT>. Eg<PRE>   Matrix A;   .....                                  // put some values in A   GenericMatrix GM = A;</PRE>A GenericMatrix matrix can be used anywhere where a matrix expression can beused and also on the left hand side of an <TT>=</TT>. You can pass any type ofmatrix (excluding the Crout and BandLUMatrix types)to a <TT>const GenericMatrix&amp;</TT> argument in a function. However mostscalar functions including Nrows(), Ncols(), Type() and element access do notwork with it. Nor does the ReturnMatrix construct. See also the paragraph on<A HREF="solve.html">LinearEquationSolver</A>.<P>An alternative and less flexible approach is to use BaseMatrix orGeneralMatrix.<P>Suppose you wish to write a function which accesses a matrix of unknowntype including expressions (eg <TT>A*B</TT>). Then use a layout similar to thefollowing:<PRE>   void YourFunction(BaseMatrix& X)   {      GeneralMatrix* gm = X.Evaluate();   // evaluate an expression                                          // if necessary      ........                            // operations on *gm      gm->tDelete();                      // delete *gm if a temporary   }</PRE>See, as an example, the definitions of <TT>operator&lt;&lt;</TT> in newmat9.cpp.<P>Under certain circumstances; particularly where <TT>X</TT> is to be used justonce in an expression you can leave out the <TT>Evaluate()</TT> statementand thecorresponding <TT>tDelete()</TT>. Just use <TT>X</TT> in the expression.<P>If you know YourFunction will never have to handle a formula as itsargument you could also use<PRE>   void YourFunction(const GeneralMatrix& X)   {      ........                            // operations on X   }</PRE>Do not try to construct a GeneralMatrix or BaseMatrix.<P><A HREF="cholesky.html">  next</A> - <A HREF="cholesky.html">  skip</A> - <A HREF="refer.html">  up</A> - <A HREF="index.html">  start</A><P></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -