Mentions légales du service

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

LateX doc : chapFirstUse.tex

parent bc900eec
Branches
Tags
No related merge requests found
......@@ -2,6 +2,7 @@
\author{Adrien Leman; Nicolas Bellot}
\title{Documentation of the project FA$\mu$ST \smallbreak "Flexible Approximate Multi-Layer Sparse Transform"}
\usepackage[]{mcode} % import matlab file
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[margin=1in]{geometry}
......
\section{Launch my first FA$\mu$ST operator}\label{sec:firstUse}
\section{QuickStart}\label{sec:firstUse}
A matlab wrapper is used to launch the FAUST C++ library.
A matlab wrapper is delivered with the FAUST C++ library.
It provides a user friendly new class of matrix \textbf{matlab{\_}faust} efficient for the multiplication with matlab built-in dense matrix class.\newline
\newline
As much as possible, a \textbf{matlab{\_}faust} object is handled as a normal matlab matrix, here is listing of matlab builtin function that can be applied to a faust A :
\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;
\end{lstlisting}
\subsection{construct a faust}\label{sec:firstUseBuild}
A \textbf{matlab{\_}faust} object can be constructed from several ways.
\subsubsection{construct a faust from a cell-array}\label{sec:firstUseBuildFromCellArray}
First, you can build a faust from a cell-array of matlab matrix (sparse or dense) representing its factors.
\newline
\newline
The following example shows how to build a random faust of size 5x3 with 3 factors :
\begin{lstlisting}
>> nb_factor = 3;
>> dim1 = 5;
>> dim2 = 3;
>>
>> % list of factors
>> factors = cell(nb_factor);
>>
>> factors{1}=rand(dim1,dim2); % first factor is rectangular
>> for i=2:nb_factor
>> factors{i}=rand(dim2,dim2);
>> end
>>
>> % build the faust
>> A=matlab_faust(factors);
\end{lstlisting}
\newpage
An optional multiplying scalar argument can be taken into account :
\begin{lstlisting}
>> % multiplicative scalar
>> lambda = 3.5
>> % build the faust
>> A=matlab_faust(factors,lambda);
\end{lstlisting}
This functionality allows you to build a faust from the factorization algorithm :
\textbf{mexHierarchical{\_}fact} or \textbf{mexPalm4MSA} :
\begin{lstlisting}
>> % factorization step
>> [lambda,factors]=mexHierarchical_fact(params);
>> % build the faust corresponding to the factorization
>> A=matlab_faust(factors,lambda);
\end{lstlisting}
\subsubsection{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=matlab_faust('faust.mat');
\end{lstlisting}
\ No newline at end of file
%%
%% This is file `mcode.sty'
%%
%% It is supposed to help you easily include MATLAB source code
%% into LaTeX document, but have it nicely highlighted, unsing
%% the great listings package.
%%
%% Usage: Include your MATLAB source code by using
%%
%% \begin{lstlisting}
%% YOUR CODE HERE
%% \end{lstlisting}
%%
%% or as an inline object via \mcode{YOURCODE}.
%%
%% For your convenience, this package has the following options:
%%
%% - bw if you intend to print the document (highlighting done
%% via text formatting (bold, italic) and shades of gray)
%%
%% - numbered if you want line numbers
%%
%% - framed if you want a frame around the source code blocks
%%
%% - final if you have ``gloablly'' set the draft option, the
%% listings package will not output the code at all. to
%% force it to do so anyway, load this package with the
%% final option (passes the ``final'' on to listings).
%%
%% Example of use: \usepackage[numbered,framed]{mcode}
%% in your document preamble.
%%
%% Note: inside code blocks you can 'escape' to LaTeX math mode
%% by using § YOUR LATEX CODE §, which is especially useful in
%% comments...
%%
%% Another feature of the listings package is that you can re-
%% place certain strings by LaTeX strings; this is used for
%% some relation symbols, see below...
%%
%% Mat Odijk pointed this out, you may include entire m-files
%% using the command \lstinputlisting{YOUR-FILE.m}. Thanks for
%% the tip!
%%
%% Feel free to edit things, and refer to the listings package
%% documentation for more infos.
%%
%% If you have any questions, feel free to ask: floz@gmx.de
%%
%% Usolved problem: long lines of code that are wrapped with
%% '...', and things thereafter being comments.....
%% but i'm working on it ;-)
%%
%% Author: Florian Knorn, floz@gmx.de
%%
%% Version history:
%% 1.2 -- Added \lstset{showstringspaces=false}
%% 1.1 -- Added \mcode command and [final] option
%% 1.0 -- Release
\def\fileversion{1.2}
\def\filedate{2005/11/17}
\typeout{Package: `mcode' \fileversion\space <\filedate>}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mcode}[\filedate\space\fileversion]
% for bw-option
\newif\ifbw
\DeclareOption{bw}{\bwtrue}
\ifbw\typeout{mcode: settings optimized for printing!}
\else\typeout{mcode: settings optimized for display!}\fi
% numbered option
\newif\ifnumbered
\DeclareOption{numbered}{\numberedtrue}
% final option
\newif\iffinal
\DeclareOption{final}{\finaltrue}
% for framed option
\newif\ifframed
\DeclareOption{framed}{\framedtrue}
\DeclareOption*{% default
\PackageWarning{mcode}{Unknown option `\CurrentOption' !}%
}
\ProcessOptions
% with this command, you can typeset syntax highlighted mcode ``inline'',
% for example when you talk about \mcode{for}--loops ...
\newcommand{\mcode}[1]{\lstinline[basicstyle=\lstbasicfont]|#1|}
% check if color command exists
\ifx\color\undefined%
\RequirePackage{color}%
\fi
% check if listings has been loaded
\ifx\lstset\undefined%
\iffinal
\RequirePackage[final]{listings}
\else
\RequirePackage{listings}
\fi
\fi
% check if textcomp has been loaded (this package is needed
% for upright quotes '' (instead of typographic ones `´)...
\ifx\textasciigrave\undefined%
\RequirePackage{textcomp}%
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% C O N F I G S --- C U S T O M I Z E H E R E %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% define the wanted font for all highlightings here
\def\lstbasicfont{\fontfamily{pcr}\selectfont}
% now let's define our own version of matlab highlighting
\lstdefinelanguage{matlabfloz}{%
alsoletter={...},%
morekeywords={% % keywords
break,case,catch,continue,elseif,else,end,for,function,global,%
if,otherwise,persistent,return,switch,try,while,...,
classdef,properties,methods},%
comment=[l]\%,% % comments
morecomment=[l]...,% % comments
morestring=[m]',% % strings
}[keywords,comments,strings]%
\ifbw % use font formating and gray 'colors'
\lstset{language=matlabfloz, % use our version of highlighting
keywordstyle=\bfseries, % keywords in bold
commentstyle=\color[gray]{0.6}\itshape, % comments light gray and italic
stringstyle=\color[gray]{0.5} % strings darker gray
}
\else% notbw => use colors : )
\lstset{language=matlabfloz, % use our version of highlighting
keywordstyle=\color[rgb]{0,0,1}, % keywords
commentstyle=\color[rgb]{0.133,0.545,0.133}, % comments
stringstyle=\color[rgb]{0.627,0.126,0.941} % strings
}
\fi%bw
\lstset{%
basicstyle={\lstbasicfont\footnotesize}, % use font and smaller size
showstringspaces=false, % do not emphasize spaces in strings
tabsize=4, % number of spaces of a TAB
mathescape=true,escapechar=§, % escape to latex with §...§
upquote=true, % upright quotes
aboveskip={1.5\baselineskip}, % a bit of space above
columns=fixed, % nice spacing
%
% the following is for replacing some matlab relations like >= or ~=
% by the corresponding LaTeX symbols, which are much easier to read ...
%% literate=%
%% {~}{{$\neg$}}1 % \neg
%% {<=}{{\tiny$\leq$}}1 % \leq
%% {>=}{{\tiny$\geq$}}1 % \geq
%% {~=}{{\tiny$\neq$}}1 % \neq
%% {delta}{{\tiny$\Delta$}}1% \Delta
}
\ifnumbered% numbered option
\lstset{%
numbersep=3mm, numbers=left, numberstyle=\tiny, % number style
}
\fi
\ifframed% framed option
\lstset{%
frame=single, % frame
}
\ifnumbered%
\lstset{%
framexleftmargin=6mm, xleftmargin=6mm % tweak margins
}
\fi
\fi
\endinput
%% End of file `mcode.sty'.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment