Commit e69e4317 authored by Roman Flury's avatar Roman Flury

spam2.2-1

parent b8a86ac9
Pipeline #1209 passed with stage
in 3 seconds
## General and platform dependent
SHELL := /bin/bash
LIBPATH = #export R_LIBS_USER=$(shell pwd)/lib:/usr/sepp1.5.1/drwho/pack-a/r-3.2.1-ro/amd64-linux-ubuntu14.04/lib/R/library:/home/furrer/R/x86_64-pc-linux-gnu-library/3.5 &&
#R := $(LIBPATH) R
#RSCRIPT := $(LIBPATH) Rscript
#LIBPATH = export R_LIBS_USER=$(shell pwd)/lib:/usr/sepp1.5.1/drwho/pack-a/r-devel-99-ro/amd64-linux-ubuntu14.04/lib/R/library:/home/furrer/R/x86_64-pc-linux-gnu-library/3.5:/usr/lib/R-devel/lib/R/library &&
R := $(LIBPATH) R ## On I-MATH servers: daily built devel version
RSCRIPT := $(LIBPATH) Rscript ## On I-MATH servers: daily built devel version
.SUFFIXES: .Rnw .R .Rout .tex .pdf .c .o .so .f
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
<h1>Illustrations and Examples</h1> <h1>Illustrations and Examples</h1>
<h4 class="author">Reinhard Furrer, Roman Flury</h4> <h4 class="author">Reinhard Furrer, Roman Flury</h4>
<h4 class="date">2018-10-11</h4> <h4 class="date">2018-12-20</h4>
<div class="hidden name"><code>spam.Rmd</code></div> <div class="hidden name"><code>spam.Rmd</code></div>
......
...@@ -114,7 +114,7 @@ ...@@ -114,7 +114,7 @@
<div id="spam-2-2-1" class="section level1"> <div id="spam-2-2-1" class="section level1">
<h1 class="page-header"> <h1 class="page-header">
<a href="#spam-2-2-1" class="anchor"></a>spam 2.2-1<small> Unreleased </small> <a href="#spam-2-2-1" class="anchor"></a>spam 2.2-1<small> 2018-12-20 </small>
</h1> </h1>
<p>SIGNIFICANT USER-VISIBLE CHANGES</p> <p>SIGNIFICANT USER-VISIBLE CHANGES</p>
<ul> <ul>
...@@ -128,7 +128,8 @@ ...@@ -128,7 +128,8 @@
</ul> </ul>
<p>INTERNAL CHANGES</p> <p>INTERNAL CHANGES</p>
<ul> <ul>
<li>spam fit for pkgdown website.</li> <li>Spam fit for pkgdown website.</li>
<li>Replacing some internal functions by their primitive equivalent.</li>
</ul> </ul>
</div> </div>
<div id="spam-2-2-0" class="section level1"> <div id="spam-2-2-0" class="section level1">
...@@ -443,8 +444,7 @@ ...@@ -443,8 +444,7 @@
<p>INTERNAL CHANGES</p> <p>INTERNAL CHANGES</p>
<ul> <ul>
<li>New much faster approach to extract rows. For not too sparse large matrices improvements over two orders of magnitudes are achieved.</li> <li>New much faster approach to extract rows. For not too sparse large matrices improvements over two orders of magnitudes are achieved.</li>
<li>Elininated ‘.Internal()’ calls that induce a ‘Note’ on CRAN checks. This also implied a minor rewrite of ‘image.spam’.<br> <li>Elininated ‘.Internal()’ calls that induce a ‘Note’ on CRAN checks. This also implied a minor rewrite of ‘image.spam’.</li>
</li>
<li>Minor code improvements.</li> <li>Minor code improvements.</li>
<li>Eliminated non-API calls (29.1).</li> <li>Eliminated non-API calls (29.1).</li>
<li>Rewritten .C(“bincode”,…) call as suggested by Brian Ripley (29.2).</li> <li>Rewritten .C(“bincode”,…) call as suggested by Brian Ripley (29.2).</li>
...@@ -469,8 +469,7 @@ ...@@ -469,8 +469,7 @@
<p>INTERNAL CHANGES</p> <p>INTERNAL CHANGES</p>
<ul> <ul>
<li>Proper storage of data files.</li> <li>Proper storage of data files.</li>
<li>Cleaning up argument names within spam functions.<br> <li>Cleaning up argument names within spam functions.</li>
</li>
<li>Cleaning up old Fortran code, i.e., eliminating unnecessary subroutines and write calls.</li> <li>Cleaning up old Fortran code, i.e., eliminating unnecessary subroutines and write calls.</li>
</ul> </ul>
<p>BUG FIXES</p> <p>BUG FIXES</p>
......
...@@ -143,8 +143,7 @@ adjacency graph.<br /></p> ...@@ -143,8 +143,7 @@ adjacency graph.<br /></p>
<h2 class="hasAnchor" id="source"><a class="anchor" href="#source"></a>Source</h2> <h2 class="hasAnchor" id="source"><a class="anchor" href="#source"></a>Source</h2>
<p>The data is available from the package <span class="pkg">INLA</span> <p>The data is available from the package <span class="pkg">INLA</span>
distributed from <a href='www.r-inla.org'>www.r-inla.org</a> or from<br /> distributed from <a href='www.r-inla.org'>www.r-inla.org</a>.</p>
<a href='http://www.math.ntnu.no/~hrue/GMRF-book/oral.txt'>http://www.math.ntnu.no/~hrue/GMRF-book/oral.txt</a></p>
<h2 class="hasAnchor" id="references"><a class="anchor" href="#references"></a>References</h2> <h2 class="hasAnchor" id="references"><a class="anchor" href="#references"></a>References</h2>
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<meta property="og:title" content="Cholesky Factorization for Sparse Matrices — chol" /> <meta property="og:title" content="Cholesky Factorization for Sparse Matrices — chol" />
<meta property="og:description" content="chol performs a Cholesky <meta property="og:description" content="chol performs a Cholesky
decomposition of a symmetric positive definite sparse matrix x decomposition of a symmetric positive definite sparse matrix x
of class spam." /> of class spam." />
<meta name="twitter:card" content="summary" /> <meta name="twitter:card" content="summary" />
...@@ -121,7 +121,7 @@ of class spam." /> ...@@ -121,7 +121,7 @@ of class spam." />
<div class="ref-description"> <div class="ref-description">
<p><code>chol</code> performs a Cholesky <p><code>chol</code> performs a Cholesky
decomposition of a symmetric positive definite sparse matrix <code>x</code> decomposition of a symmetric positive definite sparse matrix <code>x</code>
of class <code>spam</code>.</p> of class <code>spam</code>.</p>
</div> </div>
...@@ -212,7 +212,7 @@ structure can be obtained from a <code>summary</code> call, see &#8216;Examples& ...@@ -212,7 +212,7 @@ structure can be obtained from a <code>summary</code> call, see &#8216;Examples&
<code>backsolve</code> to solve a system of linear equations.<br /></p> <code>backsolve</code> to solve a system of linear equations.<br /></p>
<p>Notice that the Cholesky factorization of the package <code>SparseM</code> is also <p>Notice that the Cholesky factorization of the package <code>SparseM</code> is also
based on the algorithm of Ng and Peyton (1993). Whereas the Cholesky based on the algorithm of Ng and Peyton (1993). Whereas the Cholesky
routine of the package <code>Matrix</code> are based on routine of the package <code>Matrix</code> are based on
<code>CHOLMOD</code> by Timothy A. Davis (<code>C</code> code).</p> <code>CHOLMOD</code> by Timothy A. Davis (<code>C</code> code).</p>
<h2 class="hasAnchor" id="references"><a class="anchor" href="#references"></a>References</h2> <h2 class="hasAnchor" id="references"><a class="anchor" href="#references"></a>References</h2>
...@@ -242,7 +242,7 @@ tested for validity (defaults to <code>TRUE</code>).</p> ...@@ -242,7 +242,7 @@ tested for validity (defaults to <code>TRUE</code>).</p>
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2> <h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
<div class='dont-index'><p><code><a href='det.html'>det.spam</a></code>, <code><a href='solve.html'>solve.spam</a></code>, <div class='dont-index'><p><code><a href='det.html'>det.spam</a></code>, <code><a href='solve.html'>solve.spam</a></code>,
<code><a href='solve.html'>forwardsolve.spam</a></code>, <code><a href='solve.html'>backsolve.spam</a></code> and <code><a href='ordering.html'>ordering</a></code>.</p></div> <code><a href='solve.html'>forwardsolve.spam</a></code>, <code><a href='solve.html'>backsolve.spam</a></code> and <code><a href='ordering.html'>ordering</a></code>.</p></div>
...@@ -261,7 +261,7 @@ tested for validity (defaults to <code>TRUE</code>).</p> ...@@ -261,7 +261,7 @@ tested for validity (defaults to <code>TRUE</code>).</p>
<span class='no'>R</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='spam.creation.html'>as.spam</a></span>(<span class='no'>cholS</span>) <span class='no'>R</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='spam.creation.html'>as.spam</a></span>(<span class='no'>cholS</span>)
<span class='no'>mvsample</span> <span class='kw'>&lt;-</span> ( <span class='fu'>array</span>(<span class='fu'>rnorm</span>(<span class='no'>N</span>*<span class='no'>n</span>),<span class='fu'>c</span>(<span class='no'>N</span>,<span class='no'>n</span>)) <span class='kw'>%*%</span> <span class='no'>R</span>)[,<span class='no'>iord</span>] <span class='no'>mvsample</span> <span class='kw'>&lt;-</span> ( <span class='fu'>array</span>(<span class='fu'>rnorm</span>(<span class='no'>N</span>*<span class='no'>n</span>),<span class='fu'>c</span>(<span class='no'>N</span>,<span class='no'>n</span>)) <span class='kw'>%*%</span> <span class='no'>R</span>)[,<span class='no'>iord</span>]
<span class='co'># It is often better to order the sample than the matrix</span> <span class='co'># It is often better to order the sample than the matrix</span>
<span class='co'># R itself. </span> <span class='co'># R itself.</span>
<span class='co'># 'mvsample' is of class 'spam'. We need to transform it to a</span> <span class='co'># 'mvsample' is of class 'spam'. We need to transform it to a</span>
<span class='co'># regular matrix, as there is no method 'var' for 'spam' (should there?).</span> <span class='co'># regular matrix, as there is no method 'var' for 'spam' (should there?).</span>
......
...@@ -124,12 +124,12 @@ ...@@ -124,12 +124,12 @@
</div> </div>
<pre class="usage"><span class='fu'>rmvnorm.const</span>(<span class='no'>n</span>, <span class='kw'>mu</span> <span class='kw'>=</span> <span class='fu'>rep</span>(<span class='fl'>0</span>, <span class='fu'>nrow</span>(<span class='no'>Sigma</span>)), <span class='no'>Sigma</span>, <span class='kw'>Rstruct</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <pre class="usage"><span class='fu'>rmvnorm.const</span>(<span class='no'>n</span>, <span class='kw'>mu</span> <span class='kw'>=</span> <span class='fu'>rep.int</span>(<span class='fl'>0</span>, <span class='fu'>dim</span>(<span class='no'>Sigma</span>)[<span class='fl'>1</span>]), <span class='no'>Sigma</span>, <span class='kw'>Rstruct</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>A</span> <span class='kw'>=</span> <span class='fu'>array</span>(<span class='fl'>1</span>, <span class='fu'>c</span>(<span class='fl'>1</span>,<span class='fu'>nrow</span>(<span class='no'>Sigma</span>))), <span class='kw'>a</span><span class='kw'>=</span><span class='fl'>0</span>, <span class='kw'>U</span><span class='kw'>=</span><span class='kw'>NULL</span>, <span class='no'>...</span>) <span class='kw'>A</span> <span class='kw'>=</span> <span class='fu'>array</span>(<span class='fl'>1</span>, <span class='fu'>c</span>(<span class='fl'>1</span>,<span class='fu'>dim</span>(<span class='no'>Sigma</span>)[<span class='fl'>1</span>])), <span class='kw'>a</span><span class='kw'>=</span><span class='fl'>0</span>, <span class='kw'>U</span><span class='kw'>=</span><span class='kw'>NULL</span>, <span class='no'>...</span>)
<span class='fu'>rmvnorm.prec.const</span>(<span class='no'>n</span>, <span class='kw'>mu</span> <span class='kw'>=</span> <span class='fu'>rep</span>(<span class='fl'>0</span>, <span class='fu'>nrow</span>(<span class='no'>Q</span>)), <span class='no'>Q</span>, <span class='kw'>Rstruct</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='fu'>rmvnorm.prec.const</span>(<span class='no'>n</span>, <span class='kw'>mu</span> <span class='kw'>=</span> <span class='fu'>rep.int</span>(<span class='fl'>0</span>, <span class='fu'>dim</span>(<span class='no'>Q</span>)[<span class='fl'>1</span>]), <span class='no'>Q</span>, <span class='kw'>Rstruct</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>A</span> <span class='kw'>=</span> <span class='fu'>array</span>(<span class='fl'>1</span>, <span class='fu'>c</span>(<span class='fl'>1</span>,<span class='fu'>nrow</span>(<span class='no'>Q</span>))), <span class='kw'>a</span><span class='kw'>=</span><span class='fl'>0</span>, <span class='kw'>U</span><span class='kw'>=</span><span class='kw'>NULL</span>, <span class='no'>...</span>) <span class='kw'>A</span> <span class='kw'>=</span> <span class='fu'>array</span>(<span class='fl'>1</span>, <span class='fu'>c</span>(<span class='fl'>1</span>,<span class='fu'>dim</span>(<span class='no'>Q</span>)[<span class='fl'>1</span>])), <span class='kw'>a</span><span class='kw'>=</span><span class='fl'>0</span>, <span class='kw'>U</span><span class='kw'>=</span><span class='kw'>NULL</span>, <span class='no'>...</span>)
<span class='fu'>rmvnorm.canonical.const</span>(<span class='no'>n</span>, <span class='no'>b</span>, <span class='no'>Q</span>, <span class='kw'>Rstruct</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='fu'>rmvnorm.canonical.const</span>(<span class='no'>n</span>, <span class='no'>b</span>, <span class='no'>Q</span>, <span class='kw'>Rstruct</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>A</span> <span class='kw'>=</span> <span class='fu'>array</span>(<span class='fl'>1</span>, <span class='fu'>c</span>(<span class='fl'>1</span>,<span class='fu'>nrow</span>(<span class='no'>Q</span>))), <span class='kw'>a</span><span class='kw'>=</span><span class='fl'>0</span>, <span class='kw'>U</span><span class='kw'>=</span><span class='kw'>NULL</span>, <span class='no'>...</span>)</pre> <span class='kw'>A</span> <span class='kw'>=</span> <span class='fu'>array</span>(<span class='fl'>1</span>, <span class='fu'>c</span>(<span class='fl'>1</span>,<span class='fu'>dim</span>(<span class='no'>Q</span>)[<span class='fl'>1</span>])), <span class='kw'>a</span><span class='kw'>=</span><span class='fl'>0</span>, <span class='kw'>U</span><span class='kw'>=</span><span class='kw'>NULL</span>, <span class='no'>...</span>)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2> <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
<table class="ref-arguments"> <table class="ref-arguments">
...@@ -179,7 +179,7 @@ ...@@ -179,7 +179,7 @@
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2> <h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
<p>The functions <code>rmvnorm.prec</code> and <code>rmvnorm.canonical</code> <p>The functions <code>rmvnorm.prec</code> and <code>rmvnorm.canonical</code>
do not requrie sparse precision matrices. do not requrie sparse precision matrices.
For <code>rmvnorm.spam</code>, the differences between regular and sparse For <code>rmvnorm.spam</code>, the differences between regular and sparse
covariance matrices are too significant to be implemented here. <br /> covariance matrices are too significant to be implemented here. <br />
Often (e.g., in a Gibbs sampler setting), the sparsity structure of Often (e.g., in a Gibbs sampler setting), the sparsity structure of
......
...@@ -124,8 +124,8 @@ ...@@ -124,8 +124,8 @@
</div> </div>
<pre class="usage"><span class='fu'>rmvnorm.spam</span>(<span class='no'>n</span>,<span class='kw'>mu</span><span class='kw'>=</span><span class='fu'>rep</span>(<span class='fl'>0</span>, <span class='fu'>nrow</span>(<span class='no'>Sigma</span>)), <span class='no'>Sigma</span>, <span class='kw'>Rstruct</span><span class='kw'>=</span><span class='kw'>NULL</span>, <span class='no'>...</span>) <pre class="usage"><span class='fu'>rmvnorm.spam</span>(<span class='no'>n</span>,<span class='kw'>mu</span><span class='kw'>=</span><span class='fu'>rep.int</span>(<span class='fl'>0</span>, <span class='fu'>dim</span>(<span class='no'>Sigma</span>)[<span class='fl'>1</span>]), <span class='no'>Sigma</span>, <span class='kw'>Rstruct</span><span class='kw'>=</span><span class='kw'>NULL</span>, <span class='no'>...</span>)
<span class='fu'>rmvnorm.prec</span>(<span class='no'>n</span>,<span class='kw'>mu</span><span class='kw'>=</span><span class='fu'>rep</span>(<span class='fl'>0</span>, <span class='fu'>nrow</span>(<span class='no'>Q</span>)), <span class='no'>Q</span>, <span class='kw'>Rstruct</span><span class='kw'>=</span><span class='kw'>NULL</span>, <span class='no'>...</span>) <span class='fu'>rmvnorm.prec</span>(<span class='no'>n</span>,<span class='kw'>mu</span><span class='kw'>=</span><span class='fu'>rep.int</span>(<span class='fl'>0</span>, <span class='fu'>dim</span>(<span class='no'>Q</span>)[<span class='fl'>1</span>]), <span class='no'>Q</span>, <span class='kw'>Rstruct</span><span class='kw'>=</span><span class='kw'>NULL</span>, <span class='no'>...</span>)
<span class='fu'>rmvnorm.canonical</span>(<span class='no'>n</span>, <span class='no'>b</span>, <span class='no'>Q</span>, <span class='kw'>Rstruct</span><span class='kw'>=</span><span class='kw'>NULL</span>, <span class='no'>...</span>)</pre> <span class='fu'>rmvnorm.canonical</span>(<span class='no'>n</span>, <span class='no'>b</span>, <span class='no'>Q</span>, <span class='kw'>Rstruct</span><span class='kw'>=</span><span class='kw'>NULL</span>, <span class='no'>...</span>)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2> <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
...@@ -164,7 +164,7 @@ ...@@ -164,7 +164,7 @@
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2> <h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
<p>The functions <code>rmvnorm.prec</code> and <code>rmvnorm.canonical</code> <p>The functions <code>rmvnorm.prec</code> and <code>rmvnorm.canonical</code>
do not require sparse precision matrices. do not require sparse precision matrices.
For <code>rmvnorm.spam</code>, the differences between regular and sparse For <code>rmvnorm.spam</code>, the differences between regular and sparse
covariance matrices are too significant to be implemented here. <br /> covariance matrices are too significant to be implemented here. <br />
Often (e.g., in a Gibbs sampler setting), the sparsity structure of Often (e.g., in a Gibbs sampler setting), the sparsity structure of
...@@ -192,14 +192,14 @@ ...@@ -192,14 +192,14 @@
<span class='no'>Sigmainv</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='spam.creation.html'>as.spam</a></span>( <span class='no'>Sigmainv</span>, <span class='kw'>eps</span><span class='kw'>=</span><span class='fl'>1e-4</span>) <span class='no'>Sigmainv</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='spam.creation.html'>as.spam</a></span>( <span class='no'>Sigmainv</span>, <span class='kw'>eps</span><span class='kw'>=</span><span class='fl'>1e-4</span>)
<span class='no'>Sigma</span> <span class='kw'>&lt;-</span> <span class='fu'>solve</span>( <span class='no'>Sigmainv</span>) <span class='co'># for verification </span> <span class='no'>Sigma</span> <span class='kw'>&lt;-</span> <span class='fu'>solve</span>( <span class='no'>Sigmainv</span>) <span class='co'># for verification</span>
<span class='no'>iidsample</span> <span class='kw'>&lt;-</span> <span class='fu'>array</span>(<span class='fu'>rnorm</span>(<span class='no'>N</span>*<span class='no'>n</span>),<span class='fu'>c</span>(<span class='no'>n</span>,<span class='no'>N</span>)) <span class='no'>iidsample</span> <span class='kw'>&lt;-</span> <span class='fu'>array</span>(<span class='fu'>rnorm</span>(<span class='no'>N</span>*<span class='no'>n</span>),<span class='fu'>c</span>(<span class='no'>n</span>,<span class='no'>N</span>))
<span class='no'>mvsample</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='solve.html'>backsolve</a></span>( <span class='fu'>chol</span>(<span class='no'>Sigmainv</span>), <span class='no'>iidsample</span>) <span class='no'>mvsample</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='solve.html'>backsolve</a></span>( <span class='fu'>chol</span>(<span class='no'>Sigmainv</span>), <span class='no'>iidsample</span>)
<span class='fu'><a href='operations.html'>norm</a></span>( <span class='fu'>var</span>(<span class='fu'>t</span>(<span class='no'>mvsample</span>)) - <span class='no'>Sigma</span>, <span class='kw'>type</span><span class='kw'>=</span><span class='st'>"m"</span>)</div><div class='output co'>#&gt; [1] 0.1326448</div><div class='input'> <span class='fu'><a href='operations.html'>norm</a></span>( <span class='fu'>var</span>(<span class='fu'>t</span>(<span class='no'>mvsample</span>)) - <span class='no'>Sigma</span>, <span class='kw'>type</span><span class='kw'>=</span><span class='st'>"m"</span>)</div><div class='output co'>#&gt; [1] 0.1326448</div><div class='input'>
<span class='co'># compare with:</span> <span class='co'># compare with:</span>
<span class='no'>mvsample</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='solve.html'>backsolve</a></span>( <span class='fu'>chol</span>(<span class='fu'>as.matrix</span>( <span class='no'>Sigmainv</span>)), <span class='no'>iidsample</span>, <span class='no'>n</span>) <span class='no'>mvsample</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='solve.html'>backsolve</a></span>( <span class='fu'>chol</span>(<span class='fu'>as.matrix</span>( <span class='no'>Sigmainv</span>)), <span class='no'>iidsample</span>, <span class='no'>n</span>)
<span class='co'>#### ,n as patch </span> <span class='co'>#### ,n as patch</span>
<span class='fu'><a href='operations.html'>norm</a></span>( <span class='fu'>var</span>(<span class='fu'>t</span>(<span class='no'>mvsample</span>)) - <span class='no'>Sigma</span>, <span class='kw'>type</span><span class='kw'>=</span><span class='st'>"m"</span>)</div><div class='output co'>#&gt; [1] 0.1326447</div><div class='input'> <span class='fu'><a href='operations.html'>norm</a></span>( <span class='fu'>var</span>(<span class='fu'>t</span>(<span class='no'>mvsample</span>)) - <span class='no'>Sigma</span>, <span class='kw'>type</span><span class='kw'>=</span><span class='st'>"m"</span>)</div><div class='output co'>#&gt; [1] 0.1326447</div><div class='input'>
......
...@@ -212,7 +212,7 @@ is.spam(x)</pre> ...@@ -212,7 +212,7 @@ is.spam(x)</pre>
<span class='no'>is</span> <span class='kw'>&lt;-</span> <span class='fu'>sample</span>(<span class='no'>ln</span>,<span class='no'>nz</span>) <span class='no'>is</span> <span class='kw'>&lt;-</span> <span class='fu'>sample</span>(<span class='no'>ln</span>,<span class='no'>nz</span>)
<span class='no'>js</span> <span class='kw'>&lt;-</span> <span class='fu'>sample</span>(<span class='no'>ln</span>,<span class='no'>nz</span>) <span class='no'>js</span> <span class='kw'>&lt;-</span> <span class='fu'>sample</span>(<span class='no'>ln</span>,<span class='no'>nz</span>)
<span class='fu'>system.time</span>(<span class='kw'>for</span> (<span class='no'>i</span> <span class='kw'>in</span> <span class='fl'>1</span>:<span class='no'>nz</span>) <span class='no'>smat</span>[<span class='no'>is</span>[<span class='no'>i</span>], <span class='no'>js</span>[<span class='no'>i</span>]] <span class='kw'>&lt;-</span> <span class='no'>i</span>)</div><div class='output co'>#&gt; user system elapsed <span class='fu'>system.time</span>(<span class='kw'>for</span> (<span class='no'>i</span> <span class='kw'>in</span> <span class='fl'>1</span>:<span class='no'>nz</span>) <span class='no'>smat</span>[<span class='no'>is</span>[<span class='no'>i</span>], <span class='no'>js</span>[<span class='no'>i</span>]] <span class='kw'>&lt;-</span> <span class='no'>i</span>)</div><div class='output co'>#&gt; user system elapsed
#&gt; 0.088 0.000 0.089 </div><div class='input'><span class='fu'>system.time</span>(<span class='no'>smat</span>[<span class='fu'><a href='xybind.html'>cbind</a></span>(<span class='no'>is</span>,<span class='no'>js</span>)] <span class='kw'>&lt;-</span> <span class='fl'>1</span>:<span class='no'>nz</span>)</div><div class='output co'>#&gt; user system elapsed #&gt; 0.108 0.000 0.121 </div><div class='input'><span class='fu'>system.time</span>(<span class='no'>smat</span>[<span class='fu'><a href='xybind.html'>cbind</a></span>(<span class='no'>is</span>,<span class='no'>js</span>)] <span class='kw'>&lt;-</span> <span class='fl'>1</span>:<span class='no'>nz</span>)</div><div class='output co'>#&gt; user system elapsed
#&gt; 0.004 0.000 0.001 </div><div class='input'> #&gt; 0.004 0.000 0.001 </div><div class='input'>
<span class='fu'>getClass</span>(<span class='st'>"spam"</span>)</div><div class='output co'>#&gt; Class "spam" [package "spam"] <span class='fu'>getClass</span>(<span class='st'>"spam"</span>)</div><div class='output co'>#&gt; Class "spam" [package "spam"]
#&gt; #&gt;
......
...@@ -160,7 +160,7 @@ spam.Version() provides detailed information about the version of spam ...@@ -160,7 +160,7 @@ spam.Version() provides detailed information about the version of spam
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><div class='input'><span class='no'>spam.version</span>$<span class='no'>version.string</span></div><div class='output co'>#&gt; [1] "Spam version 2.2-1 (2018-10-11)"</div></pre> <pre class="examples"><div class='input'><span class='no'>spam.version</span>$<span class='no'>version.string</span></div><div class='output co'>#&gt; [1] "Spam version 2.2-1 (2018-12-20)"</div></pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>
......
No preview for this file type
...@@ -2,7 +2,7 @@ Package: spam ...@@ -2,7 +2,7 @@ Package: spam
Type: Package Type: Package
Title: SPArse Matrix Title: SPArse Matrix
Version: 2.2-1 Version: 2.2-1
Date: 2018-10-11 Date: 2018-12-20
Authors@R: c(person("Reinhard", "Furrer", role = c("aut", "cre"), Authors@R: c(person("Reinhard", "Furrer", role = c("aut", "cre"),
email = "reinhard.furrer@math.uzh.ch"), email = "reinhard.furrer@math.uzh.ch"),
person("Florian", "Gerber", role = c("ctb"), person("Florian", "Gerber", role = c("ctb"),
......
...@@ -2,14 +2,12 @@ ...@@ -2,14 +2,12 @@
# can be used for spam-devel and spam # can be used for spam-devel and spam
include ../Makefile.defs
all: pkgdown all: pkgdown
pkgdown: pkgdown:
$(RSCRIPT) -e "pkgdown::build_site()" Rscript -e "pkgdown::build_site()"
clean: clean:
rm -rf docs/ rm -rf docs/
...@@ -11,7 +11,8 @@ BUG FIXES ...@@ -11,7 +11,8 @@ BUG FIXES
INTERNAL CHANGES INTERNAL CHANGES
* spam fit for pkgdown website. * Spam fit for pkgdown website.
* Replacing some internal functions by their primitive equivalent.
# spam 2.2-0 # spam 2.2-0
...@@ -74,7 +75,7 @@ INTERNAL CHANGES ...@@ -74,7 +75,7 @@ INTERNAL CHANGES
INTERNAL CHANGES INTERNAL CHANGES
* Fortran modification to address more pedantic compilations. * Fortran modification to address more pedantic compilations.
# spam 1.3-0 # spam 1.3-0
...@@ -170,7 +171,7 @@ NEW FEATURES ...@@ -170,7 +171,7 @@ NEW FEATURES
* Few new S3 functions for simplicity: 'var.spam', 'eigen.spam', ... * Few new S3 functions for simplicity: 'var.spam', 'eigen.spam', ...
* New constructor functions 'colindices<-' etc. * New constructor functions 'colindices<-' etc.
Maybe additional tests may be required. Maybe additional tests may be required.
* Operators from 'Arith' obey now the structure based calculation. * Operators from 'Arith' obey now the structure based calculation.
BUG FIXES BUG FIXES
...@@ -289,7 +290,7 @@ INTERNAL CHANGES ...@@ -289,7 +290,7 @@ INTERNAL CHANGES
SIGNIFICANT USER-VISIBLE CHANGES SIGNIFICANT USER-VISIBLE CHANGES
* There is a generic conflict with 'backsolve' between spam and other packages (e.g., bdsmatrix). * There is a generic conflict with 'backsolve' between spam and other packages (e.g., bdsmatrix).
To avoid the issue, we use the standard generic implemented in 'methods' which requires an additional argument for version 0.29-0 (see also PR#14883). To avoid the issue, we use the standard generic implemented in 'methods' which requires an additional argument for version 0.29-0 (see also PR#14883).
However to maintain backwards compatibility with packages that depend on spam, this was reverted in 0.29-1. However to maintain backwards compatibility with packages that depend on spam, this was reverted in 0.29-1.
Currently, this conflict is not properly solved. Currently, this conflict is not properly solved.
I propose to load 'spam' first then the other packages, followed by manually calling: I propose to load 'spam' first then the other packages, followed by manually calling:
...@@ -328,8 +329,8 @@ NEW FEATURES ...@@ -328,8 +329,8 @@ NEW FEATURES
INTERNAL CHANGES INTERNAL CHANGES
* New much faster approach to extract rows. For not too sparse large matrices improvements over two orders of magnitudes are achieved. * New much faster approach to extract rows. For not too sparse large matrices improvements over two orders of magnitudes are achieved.
* Elininated '.Internal()' calls that induce a 'Note' on CRAN checks. This also implied a minor rewrite of 'image.spam'. * Elininated '.Internal()' calls that induce a 'Note' on CRAN checks. This also implied a minor rewrite of 'image.spam'.
* Minor code improvements. * Minor code improvements.
* Eliminated non-API calls (29.1). * Eliminated non-API calls (29.1).
* Rewritten .C("bincode",...) call as suggested by Brian Ripley (29.2). * Rewritten .C("bincode",...) call as suggested by Brian Ripley (29.2).
...@@ -351,7 +352,7 @@ NEW FEATURES ...@@ -351,7 +352,7 @@ NEW FEATURES
INTERNAL CHANGES INTERNAL CHANGES
* Proper storage of data files. * Proper storage of data files.
* Cleaning up argument names within spam functions. * Cleaning up argument names within spam functions.
* Cleaning up old Fortran code, i.e., eliminating unnecessary subroutines and write calls. * Cleaning up old Fortran code, i.e., eliminating unnecessary subroutines and write calls.
BUG FIXES BUG FIXES
...@@ -369,7 +370,7 @@ NEW FEATURES ...@@ -369,7 +370,7 @@ NEW FEATURES
* Improvements in the mle.* functions. * Improvements in the mle.* functions.
* Method diff for sparse matrices (suggested by Paul Eilers). * Method diff for sparse matrices (suggested by Paul Eilers).
* Improvement of help pages. * Improvement of help pages.
* Eliminated some help aliases to base functions (for which no 'usage' is given). * Eliminated some help aliases to base functions (for which no 'usage' is given).
INTERNAL CHANGES INTERNAL CHANGES
......
...@@ -14,14 +14,14 @@ ...@@ -14,14 +14,14 @@
"dim<-.spam" <- function(x, value) { "dim<-.spam" <- function(x, value) {
if (is.spam(x)) { if (is.spam(x)) {
dimx <- x@dimension dimx <- x@dimension
pdim <- prod(dimx) pdim <- prod(dimx)
vlen <- prod(value) vlen <- prod(value)
if( !identical(pdim,vlen)) if( !identical(pdim,vlen))
stop( sprintf("dims [product %d] do not match the length of object [%d]. Do you want `pad`", stop( sprintf("dims [product %d] do not match the length of object [%d]. Do you want `pad`",
pdim,vlen)) pdim,vlen))
if (length(value)>2) if (length(value)>2)
stop("dims should be of length 1 or 2") stop("dims should be of length 1 or 2")
if (identical(length(value),1L)) if (identical(length(value),1L))
...@@ -29,18 +29,18 @@ ...@@ -29,18 +29,18 @@
if(any(dimx<1)) if(any(dimx<1))
stop("the dims contain negative values") stop("the dims contain negative values")
tmp <- cbind(st=rep(1:dim(x)[1],diff(x@rowpointers)), nd=x@colindices) tmp <- cbind(st=rep(1:dim(x)[1],diff(x@rowpointers)), nd=x@colindices)
ind <- tmp[,1]+(tmp[,2]-1)*dimx[1] - 1 ind <- tmp[,1]+(tmp[,2]-1)*dimx[1] - 1
slist <- list(i = ind%%value[1] +1, slist <- list(i = ind%%value[1] +1,
j = ind%/%value[1] +1, j = ind%/%value[1] +1,
x@entries) x@entries)
return( spam.list( slist, nrow=value[1], ncol=value[2], return( spam.list( slist, nrow=value[1], ncol=value[2],
eps = .Machine$double.eps)) eps = .Machine$double.eps))
} else { } else {
dim(x) <- value dim(x) <- value
x x
...@@ -60,10 +60,10 @@ ...@@ -60,10 +60,10 @@
stop("dims should be postive integers.") stop("dims should be postive integers.")
if (!identical( length(value), 2L)) if (!identical( length(value), 2L))
stop("dims should be of length 2.") stop("dims should be of length 2.")
dimx <- x@dimension dimx <- x@dimension
last <- value[1]+1 last <- value[1]+1
# In three steps: # In three steps:
# 1) Address col truncation # 1) Address col truncation
# to safe time, we also take into account if we have fewer or equal rows # to safe time, we also take into account if we have fewer or equal rows
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
# 3) if fewer rows and more columns, truncate # 3) if fewer rows and more columns, truncate
# In any case, dimensions are fixed at the end. # In any case, dimensions are fixed at the end.
# If fewer cols required, we run reducedim # If fewer cols required, we run reducedim
if (dimx[2]>value[2]){ if (dimx[2]>value[2]){
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
SS <- .format64() SS <- .format64()
else else
SS <- .format32 SS <- .format32
z <- .C64("reducedim", z <- .C64("reducedim",
SIGNATURE=c("double", SS$signature, SS$signature, SIGNATURE=c("double", SS$signature, SS$signature,
"double", SS$signature, SS$signature, SS$signature, "double", SS$signature, SS$signature, SS$signature,
...@@ -89,29 +89,29 @@ ...@@ -89,29 +89,29 @@
oldra = x@entries, oldra = x@entries,
oldja = x@colindices, oldja = x@colindices,
oldia = x@rowpointers, oldia = x@rowpointers,
eps = getOption("spam.eps"), eps = getOption("spam.eps"),
min(value[1],dimx[1]), min(value[1],dimx[1]),
value[2], value[2],
nz = 1, nz = 1,
entries=vector_dc("double",length(x@entries)), entries=vector_dc("double",length(x@entries)),
colindices=vector_dc(SS$type,length(x@entries)), colindices=vector_dc(SS$type,length(x@entries)),
rowpointers=vector_dc(SS$type,last), rowpointers=vector_dc(SS$type,last),
INTENT=c("r", "r", "r", INTENT=c("r", "r", "r",
"r", "r", "r", "w", "r", "r", "r", "w",
"w", "w", "w"), "w", "w", "w"),
NAOK = getOption("spam.NAOK"), NAOK = getOption("spam.NAOK"),
PACKAGE = SS$package) PACKAGE = SS$package)
if (z$nz==1 ){ #was identical( z$nz,1L) if (z$nz==1 ){ #was identical( z$nz,1L)
## print("2") ## print("2")
return( return(
.newSpam( .newSpam(
# entries=x@entries, # entries=x@entries,
# colindices=x@colindices, # colindices=x@colindices,
# rowpointers=c(1,rep_len64(2,value[1])), # rowpointers=c(1,rep_len64(2,value[1])),
dimension=value, dimension=value,
force64=force64 force64=force64
) )
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
x <- .newSpam( x <- .newSpam(
entries=z$entries[1:nz], entries=z$entries[1:nz],
colindices=z$colindices[1:nz], colindices=z$colindices[1:nz],
rowpointers=z$rowpointers[1:min(last,dimx[1]+1)], rowpointers=z$rowpointers[1:min(last,dimx[1]+1)],
dimension=value, #actually here dim 2 = value 2 but dim1 maybe not yet dimension=value, #actually here dim 2 = value 2 but dim1 maybe not yet
force64=force64 force64=force64
) )
...@@ -140,7 +140,7 @@ ...@@ -140,7 +140,7 @@
} }
# special case: fewer rows and more columns, truncate # special case: fewer rows and more columns, truncate
if((dimx[1]>=value[1])&(dimx[2]<=value[2])) { ## added =, think about it again if((dimx[1]>=value[1])&(dimx[2]<=value[2])) { ## added =, think about it again
## print("4") ## print("4")
lastelement <- (x@rowpointers[last]-1) lastelement <- (x@rowpointers[last]-1)
...@@ -168,8 +168,8 @@ setMethod("pad<-", "matrix", ...@@ -168,8 +168,8 @@ setMethod("pad<-", "matrix",
function(x, value) { function(x, value) {
if (!identical( length(value), 2L)) stop("dims should be of length 2.") if (!identical( length(value), 2L)) stop("dims should be of length 2.")
tmp <- matrix(0, value) tmp <- matrix(0, value)
mr <- 1:min(value[1], nrow(x)) mr <- 1:min(value[1], dim(x)[1])
mc <- 1:min(value[2], ncol(x)) mc <- 1:min(value[2], dim(x)[2])
tmp[mr,mc] <- x[mr,mc] tmp[mr,mc] <- x[mr,mc]
return(tmp) return(tmp)
}) })
This diff is collapsed.
...@@ -19,18 +19,18 @@ if(! exists(".bincode", envir = .BaseNamespaceEnv)) ...@@ -19,18 +19,18 @@ if(! exists(".bincode", envir = .BaseNamespaceEnv))
.bincode <- function(v, breaks, ...) { .bincode <- function(v, breaks, ...) {
.C("bincode", as.double(v), length(v), as.double(breaks), .C("bincode", as.double(v), length(v), as.double(breaks),
length(breaks), code = integer(length(v)), as.logical(TRUE), length(breaks), code = integer(length(v)), as.logical(TRUE),
as.logical(TRUE), nok = TRUE, NAOK = TRUE, as.logical(TRUE), nok = TRUE, NAOK = TRUE,
PACKAGE = "base")$code PACKAGE = "base")$code
} }