Skip to content

Commit 50e1ffe

Browse files
committed
Started on a section 3.2 on basic container I/O
1 parent 4289ed4 commit 50e1ffe

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

ALP_Tutorial.tex

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,39 @@ \subsection{ALP/GraphBLAS Containers}
138138
Info: grb::finalize (reference) called.
139139
\end{lstlisting}
140140

141-
\noindent \textbf{Question.} Is overriding the default capacity necessary for all of \texttt{x, y, A}?
141+
\noindent \textbf{Question.} Is overriding the default capacity necessary for all of \texttt{x, y, A} in the above exercise?
142+
143+
\subsection{Basic Container I/O}
144+
145+
The containers in the C++ Standard Template Library (STL) employ the concept of iterators to ingest and extract data, as well as foresees in primitives for manipulating container contents.
146+
ALP/GraphBLAS is no different, e.g., providing \texttt{grb::clear(container)} to remove all elements from a container, similar to the clear function defined by STL vectors, sets, et cetera.
147+
Similarly, \texttt{grb::set(vector,scalar)} sets all elements of a given vector equal to the given scalar, resulting in a full (dense) vector.
148+
By contrast, \texttt{grb::setElement(vector,scalar,index)} sets only a given element at a given index equal to a given scalar.
149+
150+
\noindent \textbf{Exercise.} Start from a copy of \texttt{alp\_hw.cpp} and modify the \texttt{hello\_world} function to allocate two vectors and a matrix as follows:
151+
\begin{itemize}
152+
\item a \texttt{grb::Vector<bool>} \texttt{x} and \texttt{y} both of length $497$ with capacities $497$ and $1$, respectively;
153+
\item a \texttt{grb::Matrix<void>} \texttt{A} of size $497\times497$ and capacity $1\ 721$.
154+
\end{itemize}
155+
Then, initialise $y$ with a single value \texttt{true} at index $200$, and initialise $x$ with \texttt{false} everywhere. Print the number of nonzeroes in $x$ and $y$. Once done, after compilation and execution, the output should be alike:
156+
\begin{lstlisting}
157+
...
158+
nonzeroes in x: 497
159+
nonzeroes in y: 1
160+
...
161+
\end{lstlisting}
162+
163+
% TODO describe output iterators and print the contents of $y$
164+
165+
% TODO use output iterators to double-check $x$ has $497$ values and that all those values equal \texttt{false}
166+
167+
% TODO use input iterators to build A from west0497.mtx. Have it print the number of nonzeroes after buildMatrixUnique.
168+
169+
% TODO print the capacity of $y$.
170+
171+
% TODO Download west0497.mtx and run the application
172+
173+
% TODO Bonus question: if this is >1 and looking at the user doc, why is this OK?
142174

143175
\subsection{Semirings and Algebraic Operations}
144176

0 commit comments

Comments
 (0)