Mercurial > matrix-functions
view toolbox/chop.m @ 7:e0817ccb2834 draft
Add square root matrix function file, rename atom at funm_files, modify old toolbox to run it inside GNU Octave.
added funm_files/fun_atom.m
added sqrtm2.m
added toolbox/gecp.m
toolbox/see.m: comment wrong call to subplot
toolbox/tmtdemo.m: add a cast to double, as eig does not admit bool matrix input
removed funm_files/funm_atom.m
author | Antonio Pino Robles <data.script93@gmail.com> |
---|---|
date | Tue, 26 May 2015 18:14:54 +0200 |
parents | 8f23314345f4 |
children |
line wrap: on
line source
function c = chop(x, t) %CHOP Round matrix elements. % CHOP(X, t) is the matrix obtained by rounding the elements of X % to t significant binary places. % Default is t = 24, corresponding to IEEE single precision. if nargin < 2, t = 24; end [m, n] = size(x); % Use the representation: % x(i,j) = 2^e(i,j) * .d(1)d(2)...d(s) * sign(x(i,j)) % On the next line `+(x==0)' avoids passing a zero argument to LOG, which % would cause a warning message to be generated. y = abs(x) + (x==0); e = floor(log2(y) + 1); c = pow2(round( pow2(x, t-e) ), e-t);