📄 compressed1d.html
字号:
<HTML><!-- -- Copyright (c) 1998,1999 -- University of Notre Dame -- -- Permission to use, copy, modify, distribute and sell this software -- and its documentation for any purpose is hereby granted without fee, -- provided that the above copyright notice appears in all copies and -- that both that copyright notice and this permission notice appear -- in supporting documentation. The University of Notre Dame makes no -- representations about the suitability of this software for any -- purpose. It is provided "as is" without express or implied warranty. -- --><HEAD><TITLE>Description of compressed1D</TITLE></HEAD><BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b" ALINK="#ff0000"> <FONT FACE=Helvetica><!--end header--><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 WIDTH=100%><TR><TD><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><TR><TD Align=left valign=middle width=440 rowspan=2><FONT FACE=verdana,arial,helvetica SIZE=+3 COLOR=#110088><B>compressed1D<T, SizeType = int, int IND_OFFSET = index_from_zero></B></FONT></TD><TD valign=middle Align=right width=128 rowspan=2><A HREF="http://lsc.nd.edu/research/mtl"><IMG BORDER=0 SRC="./glossy-mtl-logo.jpg" height=48 ALT="[MTL Home]"></A></TD><TD Align=center width=280 nowrap><Font face=verdana,arial,helvetica size=+3><b>Programmers Guide</b></font></TD></TR><TR BGCOLOR='#2020b0'><TD HEIGHT=20 VALIGN='MIDDLE' NOWRAP align=center STYLE="font-family:verdana,arial,helvetica;font-weight:bold;"> <A STYLE="text-decoration:none;color:white;font-family:verdana,arial,helvetica;font-weight:bold;" HREF="./table_of_contents.html">Contents</A> | <A STYLE="text-decoration:none;color:white;font-family:verdana,arial,helvetica;font-weight:bold;" HREF="./mtl_index.html">Index</A> | <A STYLE="text-decoration:none;color:white;font-family:verdana,arial,helvetica;font-weight:bold;" HREF="http://lsc.nd.edu/research/mtl/search.html">Search</A> </TD></TR></TABLE></TD></TR><TR><TD><Table Border=0 CellPadding=0 CellSpacing=0 width=100% cols=2><TR><TD Align=left><BR><TABLE BORDER=0 CellSpacing=0 CellPadding=0><TR><TD><Img src = "containers.gif" Alt="" WIDTH = "194" HEIGHT = "38" ></TD></TR></TABLE></TD><TD Align=right><BR><TABLE BORDER=0 CellSpacing=0 CellPadding=0><TR><TD><Img src = "type.gif" Alt="" WIDTH = "194" HEIGHT = "38" ></TD></TR></TABLE></TD></TR><TR><TD Align=left VAlign=top><b>Category</b>:containers</TD><TD Align=right VAlign=top><b>Component type</b>:type</TD></TR></Table></TD></TR><TR><TD><IMG SRC="whitespace.gif" Alt="" WIDTH="32" HEIGHT="10" ALIGN="TOP"></TD></TR><TR BGCOLOR=#e0e0e0><TD VALIGN=BOTTOM><FONT FACE=arial,helvetica SIZE=+1><B>Description</B></FONT></TD></TR><TR><TD> The <A HREF="compressed1D.html" >compressed1D</A> <A HREF="Vector.html" >Vector</A> is a sparse vector implemented with a pair of parallel arrays. One <A HREF="array.html" >array</A> is for the element values, and the other <A HREF="array.html" >array</A> is for the indices of those elements. The elements are ordered by their index as they are inserted into the <A HREF="compressed1D.html" >compressed1D</A>. <A HREF="compressed1D.html" >compressed1D</A>'s can be used to build matrices with the <A HREF="array.html" >array</A> storage format, and they can also be used on their own. <pre> [ (1.2, 3), (4.6, 5), (1.0, 10), (3.7, 32) ] A Sparse <A HREF="Vector.html" >Vector</A> [ 1.2, 4.6, 1.0, 3.7 ] Value Array [ 3, 5, 10, 32 ] Index Array </pre> <p>The <tt><A HREF="compressed1D.html" >compressed1D</A>::iterator</tt> dereferences (<tt>*i</tt>) to return the element value. One can access the index of that element with the <tt>i.index()</tt> function. One can also access the <A HREF="array.html" >array</A> of indices through the <tt>nz_struct()</tt> method. <p>One particularly useful fact is that one can perform scatters and gathers of sparse elements by using the <tt>mtl::<A HREF="copy.html" >copy</A>(x,y)</tt> function with a sparse and a <A HREF="dense.html" >dense</A> vector. This method does not change the size() of the vector.</TD></TR><TR><TD><IMG SRC="whitespace.gif" Alt="" WIDTH="32" HEIGHT="15" ALIGN="TOP"></TD></TR><TR BGCOLOR=#e0e0e0><TD VALIGN=BOTTOM><FONT FACE=arial,helvetica SIZE=+1><B>Example</B></FONT></TD></TR><TR><TD>In <A HREF=../../contrib/examples/gather_scatter.cc>gather_scatter.cc</A>:<PRE>void do_gather_scatter(DenseVec& d, SparseVec& c) { using namespace mtl; c[2] = 0; c[5] = 0; c[7] = 0; gather(d,c); scale(c,2.0); scatter(c,d); typedef dense1D<double> denseVec; typedef compressed1D<double> compVec; denseVec d(9,2); compVec c; do_gather_scatter(d, c);</PRE><P>More examples can be found in <a href=../../contrib/examples/array2D.cc>array2D.cc</a>, <a href=../../contrib/examples/sparse_copy.cc>sparse_copy.cc</a></TD></TR><TR><TD><IMG SRC="whitespace.gif" Alt="" WIDTH="32" HEIGHT="15" ALIGN="TOP"></TD></TR><TR BGCOLOR=#e0e0e0><TD VALIGN=BOTTOM><FONT FACE=arial,helvetica SIZE=+1><B>Definition</B></FONT></TD></TR><TR><TD><A HREF="compressed1D.h">compressed1D.h</A></TD></TR><TR><TD><IMG SRC="whitespace.gif" Alt="" WIDTH="32" HEIGHT="15" ALIGN="TOP"></TD></TR><TR BGCOLOR=#e0e0e0><TD VALIGN=BOTTOM><FONT FACE=arial,helvetica SIZE=+1><B>Template Parameters</B></FONT></TD></TR><TR><TD><BR><TABLE BORDER><TR><TH>Parameter</TH><TH>Description</TH><TH>Default</TH></TR><TR><TD><TT>T</TT></TD><TD>the element type</TD><TD><TT> </TT></TD></TR><TR><TD><TT>SizeType</TT></TD><TD>the type for the stored indices </TD><TD><TT> int</TT></TD></TR><TR><TD><TT>IND_OFFSET</TT></TD><TD>To handle indexing from 0 or 1 </TD><TD><TT> index_from_zero</TT></TD></TR></TABLE></TD></TR><TR><TD><IMG SRC="whitespace.gif" Alt="" WIDTH="32" HEIGHT="15" ALIGN="TOP"></TD></TR><TR BGCOLOR=#e0e0e0><TD VALIGN=BOTTOM><FONT FACE=arial,helvetica SIZE=+1><B>Model of</B></FONT></TD></TR><TR><TD> <A HREF="Vector.html" >Vector</A></TD></TR><TR><TD><IMG SRC="whitespace.gif" Alt="" WIDTH="32" HEIGHT="15" ALIGN="TOP"></TD></TR><TR BGCOLOR=#e0e0e0><TD VALIGN=BOTTOM><FONT FACE=arial,helvetica SIZE=+1><B>Members</B></FONT></TD></TR><TR><TD><TABLE BORDER><TR><TH>Member</TH><TH>Where defined</TH><TH>Description</TH></TR> <TR><TD VALIGN="TOP"><TT> <TT>enum { N = 0 } </TT></TD> <TD><FONT FACE=Times SIZE=3> </FONT></TD> <TD><FONT FACE=Times SIZE=3> </FONT></TD> </TR> <TR><TD VALIGN="TOP"><TT> <TT>sparsity </TT></TD> <TD><FONT FACE=Times SIZE=3> </FONT></TD> <TD><FONT FACE=Times SIZE=3> This is a sparse vector </FONT></TD> </TR> <TR><TD VALIGN="TOP"><TT> <TT>dimension </TT></TD> <TD><FONT FACE=Times SIZE=3> </FONT></TD> <TD><FONT FACE=Times SIZE=3> This is a 1D container </FONT></TD> </TR> <TR><TD VALIGN="TOP"><TT> <TT>scaled_type </TT></TD> <TD><FONT FACE=Times SIZE=3> </FONT></TD> <TD><FONT FACE=Times SIZE=3> Scaled type of this vector </FONT></TD> </TR> <TR><TD VALIGN="TOP"><TT> <TT>value_type </TT></TD> <TD><FONT FACE=Times SIZE=3> </FONT></TD> <TD><FONT FACE=Times SIZE=3> Element type </FONT></TD> </TR> <TR><TD VALIGN="TOP"><TT> <TT>pointer </TT></TD> <TD><FONT FACE=Times SIZE=3> </FONT></TD> <TD><FONT FACE=Times SIZE=3> A pointer to the element type </FONT></TD> </TR> <TR><TD VALIGN="TOP"><TT> <TT>size_type </TT></TD> <TD><FONT FACE=Times SIZE=3> </FONT></TD> <TD><FONT FACE=Times SIZE=3> Unsigned integral type for dimensions and indices </FONT></TD> </TR> <TR><TD VALIGN="TOP"><TT> <TT>difference_type </TT></TD> <TD><FONT FACE=Times SIZE=3> </FONT></TD> <TD><FONT FACE=Times SIZE=3> Integral type for differences in iterators </FONT></TD> </TR> <TR><TD VALIGN="TOP"><TT> <TT>reference </TT></TD> <TD><FONT FACE=Times SIZE=3> </FONT></TD> <TD><FONT FACE=Times SIZE=3> Reference to the value type </FONT></TD> </TR> <TR><TD VALIGN="TOP"><TT> <TT>const_reference </TT></TD> <TD><FONT FACE=Times SIZE=3> </FONT></TD> <TD><FONT FACE=Times SIZE=3> Const reference to the value type </FONT></TD> </TR> <TR><TD VALIGN="TOP"><TT> <TT>iterator </TT></TD> <TD><FONT FACE=Times SIZE=3> </FONT></TD> <TD><FONT FACE=Times SIZE=3> Iterator type </FONT></TD> </TR> <TR><TD VALIGN="TOP"><TT> <TT>const_iterator </TT></TD> <TD><FONT FACE=Times SIZE=3> </FONT></TD> <TD><FONT FACE=Times SIZE=3> Const iterator type </FONT></TD> </TR> <TR><TD VALIGN="TOP"><TT> <TT>reverse_iterator </TT></TD> <TD><FONT FACE=Times SIZE=3> </FONT></TD> <TD><FONT FACE=Times SIZE=3> Reverse iterator type </FONT></TD> </TR> <TR><TD VALIGN="TOP"><TT> <TT>const_reverse_iterator </TT></TD> <TD><FONT FACE=Times SIZE=3> </FONT></TD> <TD><FONT FACE=Times SIZE=3> The const reverse iterator type </FONT></TD> </TR> <TR><TD VALIGN="TOP"><TT> <TT>IndexArrayRef </TT></TD> <TD><FONT FACE=Times SIZE=3> </FONT></TD> <TD><FONT FACE=Times SIZE=3> Reference to the index <A HREF="array.html" >array</A> </FONT></TD> </TR> <TR><TD VALIGN="TOP"><TT> <TT>IndexArray </TT></TD> <TD><FONT FACE=Times SIZE=3> </FONT></TD> <TD><FONT FACE=Times SIZE=3> The type for the index <A HREF="array.html" >array</A> </FONT></TD> </TR> <TR><TD VALIGN="TOP"><TT> <TT>subrange_type </TT></TD> <TD><FONT FACE=Times SIZE=3> </FONT></TD> <TD><FONT FACE=Times SIZE=3> The type for the subrange vector </FONT></TD>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -