Mercurial > hg > octave-nkf
comparison src/DLD-FUNCTIONS/sparse.cc @ 6556:8810bbf321ce
[project @ 2007-04-20 18:39:40 by jwe]
author | jwe |
---|---|
date | Fri, 20 Apr 2007 18:39:41 +0000 |
parents | 4fb053f24fd6 |
children | 9883cb21e2aa |
comparison
equal
deleted
inserted
replaced
6555:69e864d21c11 | 6556:8810bbf321ce |
---|---|
59 return octave_value (is_sparse (args(0))); | 59 return octave_value (is_sparse (args(0))); |
60 } | 60 } |
61 | 61 |
62 DEFUN_DLD (sparse, args, , | 62 DEFUN_DLD (sparse, args, , |
63 "-*- texinfo -*-\n\ | 63 "-*- texinfo -*-\n\ |
64 @deftypefn {Loadable Function} {@var{sparse_val} =} sparse (@dots{})\n\ | 64 @deftypefn {Loadable Function} {@var{s} =} sparse (@var{a})\n\ |
65 SPARSE: create a sparse matrix\n\ | 65 Create a sparse matrix from the full matrix @var{a}.\n\ |
66 \n\ | |
67 sparse can be called in the following ways:\n\ | |
68 \n\ | |
69 @enumerate\n\ | |
70 @item @var{S} = sparse(@var{A}) where @var{A} is a full matrix\n\ | |
71 \n\ | |
72 @item @var{S} = sparse(@var{A},1) where @var{A} is a full matrix, result\n\ | |
73 is forced back to a full matrix is resulting matrix is sparse\n\ | 66 is forced back to a full matrix is resulting matrix is sparse\n\ |
74 \n\ | 67 \n\ |
75 @item @var{S} = sparse(@var{i},@var{j},@var{s},@var{m},@var{n},@var{nzmax}) where\n\ | 68 @deftypefnx {Loadable Function} {@var{s} =} sparse (@var{a}, 1)\n\ |
76 @itemize @w \n\ | 69 Create a sparse matrix and convert it back to a full matrix.\n\ |
77 @var{i},@var{j} are integer index vectors (1 x nnz) @* \n\ | 70 is forced back to a full matrix is resulting matrix is sparse\n\ |
78 @var{s} is the vector of real or complex entries (1 x nnz) @* \n\ | 71 \n\ |
79 @var{m},@var{n} are the scalar dimentions of S @* \n\ | 72 @deftypefnx {Loadable Function} {@var{s} =} sparse (@var{i}, @var{j}, @var{sv}, @var{m}, @var{n}, @var{nzmax})\n\ |
80 @var{nzmax} is ignored (here for compatability with Matlab) @* \n\ | 73 Create a sparse matrix given integer index vectors @var{i} and @var{j},\n\ |
81 \n\ | 74 a 1-by-@code{nnz} vector of real of complex values @var{sv}, overall\n\ |
82 if multiple values are specified with the same @var{i},@var{j}\n\ | 75 dimensions @var{m} and @var{n} of the sparse matrix. The argument\n\ |
83 position, the corresponding values in @var{s} will be added\n\ | 76 @code{nzmax} is ignored but accepted for compatability with @sc{Matlab}.\n\ |
84 @end itemize\n\ | 77 \n\ |
85 \n\ | 78 @strong{Note}: if multiple values are specified with the same\n\ |
86 @item The following usages are equivalent to (2) above:\n\ | 79 @var{i}, @var{j} indices, the corresponding values in @var{s} will\n\ |
87 @itemize @w \n\ | 80 be added.\n\ |
88 @var{S} = sparse(@var{i},@var{j},@var{s},@var{m},@var{n})@*\n\ | 81 \n\ |
89 @var{S} = sparse(@var{i},@var{j},@var{s},@var{m},@var{n},'summation')@*\n\ | 82 @item The following usages are equivalent:\n\ |
90 @var{S} = sparse(@var{i},@var{j},@var{s},@var{m},@var{n},'sum')@*\n\ | 83 \n\ |
91 @end itemize\n\ | 84 @example\n\ |
92 \n\ | 85 @group\n\ |
93 @item @var{S} = sparse(@var{i},@var{j},@var{s},@var{m},@var{n},'unique')@*\n\ | 86 s = sparse (i, j, s, m, n)\n\ |
94 \n\ | 87 s = sparse (i, j, s, m, n, \"summation\")\n\ |
95 @itemize @w \n\ | 88 s = sparse (i, j, s, m, n, \"sum\")\n\ |
96 same as (2) above, except that rather than adding,\n\ | 89 @end group\n\ |
97 if more than two values are specified for the same @var{i},@var{j}\n\ | 90 @end example\n\ |
98 position, then the last specified value will be kept\n\ | 91 \n\ |
99 @end itemize\n\ | 92 @deftypefnx {Loadable Function} {@var{s} =} sparse (@var{i}, @var{j}, @var{s}, @var{m}, @var{n}, \"unique\")\n\ |
100 \n\ | 93 Same as above, except that if more than two values are specified for the\n\ |
101 @item @var{S}= sparse(@var{i},@var{j},@var{sv}) uses @var{m}=max(@var{i}), @var{n}=max(@var{j})\n\ | 94 same @var{i}, @var{j} indices, the last specified value will be used.\n\ |
102 \n\ | 95 \n\ |
103 @item @var{S}= sparse(@var{m},@var{n}) does sparse([],[],[],@var{m},@var{n},0)\n\ | 96 @deftypefnx {Loadable Function} {@var{s} =} sparse (@var{i}, @var{j}, @var{sv})\n\ |
104 \n\ | 97 Uses @code{@var{m} = max (@var{i})}, @code{@var{n} = max (@var{j})}\n\ |
105 @var{sv}, and @var{i} or @var{j} may be scalars, in\n\ | 98 \n\ |
106 which case they are expanded to all have the same length\n\ | 99 @deftypefnx {Loadable Function} {@var{s} =} sparse (@var{m}, @var{n})\n\ |
107 @end enumerate\n\ | 100 Equivalent to @code{sparse ([], [], [], @var{m}, @var{n}, 0)}\n\ |
101 \n\ | |
102 If any of @var{sv}, @var{i} or @var{j} are scalars, they are expanded\n\ | |
103 to have a common size.\n\ | |
108 @seealso{full}\n\ | 104 @seealso{full}\n\ |
109 @end deftypefn") | 105 @end deftypefn") |
110 { | 106 { |
111 octave_value retval; | 107 octave_value retval; |
112 bool mutate = false; | 108 bool mutate = false; |