Mercurial > hg > octave-nkf
changeset 6252:738c97e101eb
[project @ 2007-01-24 19:58:46 by jwe]
author | jwe |
---|---|
date | Wed, 24 Jan 2007 19:58:46 +0000 |
parents | 27f85707054a |
children | f1676652d808 |
files | scripts/ChangeLog scripts/elfun/tand.m scripts/miscellaneous/news.m scripts/pkg/pkg.m scripts/sparse/sprandsym.m |
diffstat | 5 files changed, 78 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,11 @@ +2007-01-24 David Bateman <dbateman@free.fr> + + * sparse/sprandsym.m: Make work for even values of N. + +2007-01-24 John W. Eaton <jwe@octave.org> + + * miscellaneous/news.m: New file. + 2007-01-23 Luis F. Ortiz <lortiz@interactivesupercomputing.com> * strings/strncmpi.m: Use strncmp instead of calling strtrunc on args. @@ -14,6 +22,9 @@ 2007-01-18 Søren Hauberg <hauberg@gmail.com> + * pkg/pkg.m (copy_files): Call write_INDEX with correct target + file name. + * image/ind2rgb.m: Better input checking. Return 3-d array if nargout is 1. Handle colormaps that have too few colors.
--- a/scripts/elfun/tand.m +++ b/scripts/elfun/tand.m @@ -18,7 +18,7 @@ ## @deftypefn {Function File} {} tand (@var{x}) ## Compute the tangent of an angle in degrees. Returns zero for elements ## of for which @code{@var{x}/180} is an integer and @code{Inf} for elements -## where @code{(@var{x}-90}/180} is an integer. +## where @code{(@var{x}-90)/180} is an integer. ## @seealso{tan, cosd, sind, acosd, asind, atand} ## @end deftypefn
new file mode 100644 --- /dev/null +++ b/scripts/miscellaneous/news.m @@ -0,0 +1,39 @@ +## Copyright (C) 2007 John W. Eaton +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2, or (at your option) +## any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, write to the Free +## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +## 02110-1301, USA. + +## -*- texinfo -*- +## @deftypefn {Function File} {} news () +## Display the current NEWS file for Octave. +## @end deftypefn + +function news () + + datadir = octave_config_info ("datadir"); + newsfile = fullfile (datadir, "octave", version (), "NEWS"); + + if (exist (newsfile, "file")) + f = fopen (newsfile, "r"); + while (isstr (line = fgets (f))) + printf (line); + endwhile + else + error ("news: unable to locate NEWS file"); + endif + +endfunction
--- a/scripts/pkg/pkg.m +++ b/scripts/pkg/pkg.m @@ -775,7 +775,8 @@ endif else try - write_INDEX(desc, fullfile(packdir, "inst"), fINDEX); + write_INDEX(desc, fullfile(packdir, "inst"), fullfile(packinfo, "IND +EX")); catch rm_rf(desc.dir); error(lasterr);
--- a/scripts/sparse/sprandsym.m +++ b/scripts/sparse/sprandsym.m @@ -32,42 +32,40 @@ ## @seealso{sprand, sprandn} ## @end deftypefn -function S = sprandsym(n,d) - if nargin == 1 - [i,j,v,nr,nc] = spfind(tril(n)); - S = sparse(i,j,randn(size(v)),nr,nc); - S = S + tril(S,-1)'; - elseif nargin == 2 - m1 = floor(n/2); - n1 = m1 + 1; +function S = sprandsym (n, d) + if (nargin == 1) + [i, j, v, nr, nc] = spfind (tril (n)); + S = sparse (i, j, randn (size (v)), nr, nc); + S = S + tril (S, -1)'; + elseif (nargin == 2) + m1 = floor (n/2); + n1 = m1 + rem (n, 2); mn1 = m1*n1; - k1 = round(d*mn1); - idx1=unique(fix(rand(min(k1*1.01,k1+10),1)*mn1))+1; - # idx contains random numbers in [1,mn] - # generate 1% or 10 more random values than necessary - # in order to reduce the probability that there are less than k - # distinct values; - # maybe a better strategy could be used - # but I don't think it's worth the price - k1 = min(length(idx1),k1); # actual number of entries in S - j1 = floor((idx1(1:k1)-1)/m1); + k1 = round (d*mn1); + idx1 = unique (fix(rand(min(k1*1.01,k1+10),1)*mn1))+1; + ## idx contains random numbers in [1,mn] generate 1% or 10 more + ## random values than necessary in order to reduce the probability + ## that there are less than k distinct values; maybe a better + ## strategy could be used but I don't think it's worth the price. + k1 = min (length (idx1), k1); # actual number of entries in S + j1 = floor ((idx1(1:k1)-1)/m1); i1 = idx1(1:k1) - j1*m1; - n2 = ceil(n/2); + n2 = ceil (n/2); nn2 = n2*n2; - k2 = round(d*nn2); - idx2=unique(fix(rand(min(k2*1.01,k1+10),1)*nn2))+1; - k2 = min(length(idx2),k2); - j2 = floor((idx2(1:k2)-1)/n2); + k2 = round (d*nn2); + idx2 = unique (fix (rand (min (k2*1.01, k1+10), 1)*nn2)) + 1; + k2 = min (length (idx2), k2); + j2 = floor ((idx2(1:k2)-1)/n2); i2 = idx2(1:k2) - j2*n2; - if isempty(i1) && isempty(i2) - S = sparse(n,n); + if (isempty (i1) && isempty (i2)) + S = sparse (n, n); else - S1 = sparse(i1,j1+1,randn(k1,1),m1,n1); + S1 = sparse (i1, j1+1, randn (k1, 1), m1, n1); S = [tril(S1), sparse(m1,m1); ... sparse(i2,j2+1,randn(k2,1),n2,n2), triu(S1,1)']; - S = S + tril(S,-1)'; + S = S + tril (S, -1)'; endif else print_usage ();