Mentions légales du service

Skip to content
Snippets Groups Projects
Commit abc589fb authored by Nicolas Bellot's avatar Nicolas Bellot Committed by hhakim
Browse files

Latex Documentation chapter Quick Start

parent 4e8e756a
Branches
Tags
No related merge requests found
\chapter{QuickStart}\label{sec:firstUse}
A Matlab wrapper is delivered with the FA$\mu$ST C++ library.
\paragraph{}A Matlab wrapper is delivered with the FA$\mu$ST C++ library.
It provides a user friendly new class of matrix \textbf{Faust} efficient for the multiplication with matlab built-in dense matrix class.\newline
\newline
As much as possible, a \textbf{Faust} object is handled as a normal matlab matrix, here is listing of matlab builtin function that can be applied to a Faust A :
In order to use matlab wrapper after the installation of Faust, launch Matlab.
In the Matlab terminal, set your working directory to /"HOMEDIR"/Documents/MATLAB/Faust and set the Matlab path by typing the following commands :
\begin{lstlisting}
>> % considering A is a Faust of size 10x3
>>
>> % get the size of the faust
>> [dim1,dim2] = size(A);
>>
>> % transpose a faust
>> A_trans = A';
>>
>> % multiplication by A
>> x1 = rand(3,3);
>> y1 = A*x1;
>>
>> % multiplication by A'
>> x2 = rand(10,5);
>> y2 = A'*x2;
>>
>>
>> % get the 2-norm (spectral norm) of the faust A
>> norm_A = norm(A); % equivalent to norm(A,2);
>>
>> % get the coefficient i,j and slicing for reading purpose
>> coeff=A(i,j);
>> col_2=A(:,2);
>> submatrix_A=A(3:5,2:3);
>> submatrix_A=A(2:end,3:end-1);
>> % Warning : A(i,j)=3 will not modify A, writing is not allowed
>>
>> % get the number of non-zeros coefficient
>> nz = nnz(A);
cd /"HOMEDIR"/Documents/MATLAB/Faust
setup_Faust
\end{lstlisting}
\subsection{Use a faust from a saved one}\label{sec:firstUseBuildFromSave}
\paragraph{} Now, you can run quick\_start.m script in the Matlab terminal by typing :
\begin{lstlisting}
quick_start
\end{lstlisting}
\paragraph{}In this script, first of all, a Faust of size 4000x5000 is loaded from a previous one that is saved into a matfile :
\lstinputlisting[firstline=47,lastline=48]{../../misc/demo/Quick_start/quick_start.m}
\paragraph{}Secondly, a list of overloaded matlab function shows that a Faust is handled as a normal Matlab builtin matrix.
\lstinputlisting[firstline=51,lastline=78]{../../misc/demo/Quick_start/quick_start.m}
\paragraph{}Finally, it performs a little time comparison between multiplication by a Faust or its full matrix equivalent.
This is in order to illustrate the speed-up induced by the Faust. This speed-up should be around 30 (depending on your machine).
\lstinputlisting[firstline=84,lastline=100]{../../misc/demo/Quick_start/quick_start.m}
\section{construct a faust}\label{sec:firstUseBuild}
A \textbf{Faust} object can be constructed from several ways.
\subsection{construct a faust from a cell-array}\label{sec:firstUseBuildFromCellArray}
\subsection{Other ways to build a Faust}\label{sec:firstUseBuildFromCellArray}
\paragraph{} A Faust can initialized from a matrix or from a cell-array storing its factors.
\subsubsection{build a Faust from a matrix and parameters}\label{sec:firstUseBuildFromMatrix}
First, you can build a Faust from a cell-array of matlab matrix (sparse or dense) representing its factors.
\newline
\newline
......@@ -60,9 +46,9 @@ The following example shows how to build a random faust of size 5x3 with 3 facto
>> % list of factors
>> factors = cell(nb_factor);
>>
>> factors{1}=rand(dim1,dim2); % first factor is rectangular
>> factors{1}=sprand(dim1,dim2,0.1); % first factor is rectangular and sparse
>> for i=2:nb_factor
>> factors{i}=rand(dim2,dim2);
>> factors{i}=rand(dim2,dim2); % second is sparse
>> end
>>
>> % build the faust
......@@ -87,13 +73,5 @@ This functionality allows you to build a Faust from the factorization algorithm
>> A=Faust(factors,lambda);
\end{lstlisting}
\subsection{construct a faust from a saved one}\label{sec:firstUseBuildFromSave}
You can also build a Faust from a previously one which is saved into a mat file :
\begin{lstlisting}
>> % save the faust A into the file faust.mat
>> [lambda,factors]=save(A,'faust.mat');
>> % create a new faust from the file faust.mat
>> A_loaded=Faust('faust.mat');
\end{lstlisting}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment