comparison main/sparsersb/src/sparsersb.cc @ 12642:a95bee17f7fd octave-forge

reorganized the documentation string to have the @deftypefnx lines one after the other. small documentation bugs corrected on the way.
author michelemartone
date Sun, 21 Jun 2015 14:34:28 +0000
parents 061284acaabd
children dc5803650a98
comparison
equal deleted inserted replaced
12641:e3998369a32e 12642:a95bee17f7fd
218 #define RSBOI_BINOP_PREVAILING_TYPE(V1,V2) (((V1).is_complex_type()||(V2).is_complex_type())?RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX:RSB_NUMERICAL_TYPE_DOUBLE) 218 #define RSBOI_BINOP_PREVAILING_TYPE(V1,V2) (((V1).is_complex_type()||(V2).is_complex_type())?RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX:RSB_NUMERICAL_TYPE_DOUBLE)
219 #else 219 #else
220 #define RSBOI_BINOP_PREVAILING_TYPE(V1,V2) RSBOI_TYPECODE 220 #define RSBOI_BINOP_PREVAILING_TYPE(V1,V2) RSBOI_TYPECODE
221 #endif 221 #endif
222 #if defined(RSB_LIBRSB_VER) && (RSB_LIBRSB_VER>=10100) 222 #if defined(RSB_LIBRSB_VER) && (RSB_LIBRSB_VER>=10100)
223 #define RSBOI_10100_DOCH \
224 "@deftypefnx {Loadable Function} {@var{s} =} "RSBOI_FNS" (@var{A},\"render\", @var{filename}[, @var{rWidth}, @var{rHeight}])\n"\
225 "@deftypefnx {Loadable Function} {[@var{O} =]} "RSBOI_FNS" (@var{A},\"autotune\"[, @var{transA}, @var{nrhs}, @var{maxr}, @var{tmax}, @var{tn}, @var{sf}])\n"\
226
223 #define RSBOI_10100_DOC \ 227 #define RSBOI_10100_DOC \
224 "@deftypefnx {Loadable Function} {@var{s} =} "RSBOI_FNS" (@var{A},\"render\", @var{filename}[, @var{rWidth}, @var{rHeight}])\n"\ 228 \
225 "If @var{A} is a "RSBOI_FNS" matrix and @var{filename} is a string, @var{A} will be rendered as an Encapsulated Postcript file @var{filename}. Optionally, width and height can be specified. Defaults are 512.\n"\ 229 "If @var{A} is a "RSBOI_FNS" matrix and the \"render\" keyword is specified, and @var{filename} is a string, @var{A} will be rendered as an Encapsulated Postcript file @var{filename}. Optionally, width and height can be specified in @code{@var{rWidth}, @var{rHeight}}. Defaults are 512.\n"\
226 "@deftypefnx {Loadable Function} {[@var{O} =]} "RSBOI_FNS" (@var{A},\"autotune\"[, @var{transA}, @var{nrhs}, @var{maxr}, @var{tmax}, @var{tn}, @var{sf}])\n"\ 230 "\n"\
227 "If @var{A} is a "RSBOI_FNS" matrix, autotuning of the matrix will take place, with SpMV and autotuning parameters. After the \"autotune\" string, the remaining parameters are optional. If giving an output argument @var{O}, that will be assigned to the autotuned matrix, and the input one @var{A} will remain unchanged.\n" 231 \
232 "If @var{A} is a "RSBOI_FNS" matrix and the \"autotune\" keyword is specified, autotuning of the matrix will take place, with SpMV and autotuning parameters. After the \"autotune\" string, the remaining parameters are optional. Parameter @var{transA} specifies whether to tune for untransposed (\"n\") or transposed (\"t\"); @var{nrhs} the number of right hand sides; @var{maxr} the number of tuning rounds; @var{tmax} the threads to use. If giving an output argument @var{O}, that will be assigned to the autotuned matrix, and the input one @var{A} will remain unchanged. See librsb documentation for @code{rsb_tune_spmm} to learn more.\n"
228 #else 233 #else
229 #define RSBOI_10100_DOC "" 234 #define RSBOI_10100_DOC ""
235 #define RSBOI_10100_DOCH ""
230 #endif 236 #endif
231 237
232 void rsboi_strerr(rsb_err_t errval) 238 void rsboi_strerr(rsb_err_t errval)
233 { 239 {
234 const int errstrlen=128; 240 const int errstrlen=128;
1912 } 1918 }
1913 1919
1914 DEFUN_DLD (RSB_SPARSERSB_LABEL, args, nargout, 1920 DEFUN_DLD (RSB_SPARSERSB_LABEL, args, nargout,
1915 "-*- texinfo -*-\n\ 1921 "-*- texinfo -*-\n\
1916 @deftypefn {Loadable Function} {@var{s} =} "RSBOI_FNS" (@var{a})\n\ 1922 @deftypefn {Loadable Function} {@var{s} =} "RSBOI_FNS" (@var{a})\n\
1917 Create a sparse RSB matrix from the full matrix @var{a}.\n"\ 1923 @deftypefnx {Loadable Function} {@var{s} =} "RSBOI_FNS" (@var{i}, @var{j}, @var{sv}, @var{m}, @var{n})\n\
1918 /*is forced back to a full matrix if resulting matrix is sparse\n*/\ 1924 @deftypefnx {Loadable Function} {@var{s} =} "RSBOI_FNS" (@var{i}, @var{j}, @var{sv}, @var{m}, @var{n}, @var{nzmax})\n\
1925 @deftypefnx {Loadable Function} {@var{s} =} "RSBOI_FNS" (@var{i}, @var{j}, @var{sv})\n\
1926 @deftypefnx {Loadable Function} {@var{s} =} "RSBOI_FNS" (@var{m}, @var{n})\n\
1927 @deftypefnx {Loadable Function} {@var{s} =} "RSBOI_FNS" (@var{i}, @var{j}, @var{s}, @var{m}, @var{n}, \"unique\")\n\
1928 @deftypefnx {Loadable Function} {@var{s} =} "RSBOI_FNS" (\"set\", @var{opn}, @var{opv})\n\
1929 @deftypefnx {Loadable Function} {@var{s} =} "RSBOI_FNS" (@var{A}, \"get\", @var{mif})\n\
1930 @deftypefnx {Loadable Function} {@var{s} =} "RSBOI_FNS" (@var{A}, @var{QS})\n\
1931 @deftypefnx {Loadable Function} "RSBOI_FNS" (@var{a},\"save\",@var{mtxfilename})\n\
1932 @deftypefnx {Loadable Function} {[@var{s}, @var{nrows}, @var{ncols}, @var{nnz}, @var{repinfo}, @var{field}, @var{symmetry}] =} "RSBOI_FNS" (@var{mtxfilename}, @var{mtxtypestring})\n\
1933 "RSBOI_10100_DOCH""\
1934 \
1935 "\n"\
1936 "Create or manipulate sparse matrices using the RSB format provided by librsb, as similarly as possible to @code{sparse}.\n"\
1937 "\n"\
1938 "If @var{a} is a full matrix, convert it to a sparse matrix representation,\n\
1939 removing all zero values in the process.\n"\
1919 "\n\ 1940 "\n\
1920 @deftypefnx {Loadable Function} {[@var{s}, @var{nrows}, @var{ncols}, @var{nnz}, @var{repinfo}, @var{field}, @var{symmetry}] =} "RSBOI_FNS" (@var{mtxfilename}, @var{mtxtypestring})\n\ 1941 Given the integer index vectors @var{i} and @var{j}, and a 1-by-@code{nnz}\n\
1921 Create a sparse RSB matrix by loading the Matrix Market matrix file named @var{mtxfilename}. The optional argument @var{mtxtypestring} can specify either real (\"D\") or complex (\"Z\") type. Default is real.\n"\ 1942 vector of real or complex values @var{sv}, construct the sparse matrix\n\
1922 "In the case @var{mtxfilename} is \""RSBOI_LIS"\", a string listing the available numerical types with BLAS-style characters will be returned. If the file turns out to contain a Matrix Market vector, this will be loaded as such.\n"\ 1943 @code{S(@var{i}(@var{k}),@var{j}(@var{k})) = @var{sv}(@var{k})} with overall\n\
1923 1944 dimensions @var{m} and @var{n}. \n\
1924 1945 \nThe argument\n\
1946 @code{@var{nzmax}} is ignored but accepted for compatibility with @sc{Matlab} and @code{sparsersb}.\n\
1947 \n\
1948 If @var{m} or @var{n} are not specified their values are derived from the\n\
1949 maximum index in the vectors @var{i} and @var{j} as given by\n\
1950 @code{@var{m} = max (@var{i})}, @code{@var{n} = max (@var{j})}.\n\
1951 \n\
1952 \
1953 Can load a matrix from a Matrix Market matrix file named @var{mtxfilename}. The optional argument @var{mtxtypestring} can specify either real (\"D\") or complex (\"Z\") type. Default is real.\n"\
1954 "In the case @var{mtxfilename} is \""RSBOI_LIS"\", a string listing the available numerical types with BLAS-style characters will be returned. If the file turns out to contain a Matrix Market dense vector, this will be loaded.\n"\
1955 \
1956 \
1925 "\n\ 1957 "\n\
1926 @deftypefnx {Loadable Function} "RSBOI_FNS" (@var{a},\"save\",@var{mtxfilename})\n\ 1958 \
1927 Saves a sparse RSB matrix as a Matrix Market matrix file named @var{mtxfilename}.\n"\ 1959 If \"save\" is specified, saves a sparse RSB matrix as a Matrix Market matrix file named @var{mtxfilename}.\n"\
1928 "\n\ 1960 "\n\
1929 @deftypefnx {Loadable Function} {@var{s} =} "RSBOI_FNS" (@var{i}, @var{j}, @var{sv}, @var{m}, @var{n}, @var{nzmax})\n\ 1961 \
1930 Create a sparse RSB matrix given integer index vectors @var{i} and @var{j},\n\
1931 a 1-by-@code{nnz} vector of real of complex values @var{sv}, overall\n\
1932 dimensions @var{m} and @var{n} of the sparse matrix. The argument\n\
1933 @code{nzmax} is ignored but accepted for compatibility with @sc{Matlab}.\n\
1934 \n\
1935 @strong{Note}: if multiple values are specified with the same\n\ 1962 @strong{Note}: if multiple values are specified with the same\n\
1936 @var{i}, @var{j} indices, the corresponding values in @var{s} will\n\ 1963 @var{i}, @var{j} indices, the corresponding values in @var{s} will\n\
1937 be added.\n\ 1964 be added.\n\
1938 \n\ 1965 \n\
1939 The following are all equivalent:\n\ 1966 The following are all equivalent:\n\
1946 /*"s = "RSBOI_FNS" (i, j, s, \"summation\")\n"*/\ 1973 /*"s = "RSBOI_FNS" (i, j, s, \"summation\")\n"*/\
1947 /*"s = "RSBOI_FNS" (i, j, s, \"sum\")\n"*/\ 1974 /*"s = "RSBOI_FNS" (i, j, s, \"sum\")\n"*/\
1948 "@end group\n\ 1975 "@end group\n\
1949 @end example\n\ 1976 @end example\n\
1950 \n\ 1977 \n\
1951 @deftypefnx {Loadable Function} {@var{s} =} "RSBOI_FNS" (@var{i}, @var{j}, @var{s}, @var{m}, @var{n}, \"unique\")\n\ 1978 \
1952 Same as above, except that if more than two values are specified for the\n\ 1979 If the optional \"unique\" keyword is specified, then if more than two values are specified for the\n\
1953 same @var{i}, @var{j} indices, the last specified value will be used.\n\ 1980 same @var{i}, @var{j} indices, only the last value will be used.\n\
1954 \n\ 1981 \n\
1955 @deftypefnx {Loadable Function} {@var{s} =} "RSBOI_FNS" (@var{i}, @var{j}, @var{sv})\n\ 1982 @code{"RSBOI_FNS" (@var{m}, @var{n})} will create an empty @var{m}x@var{n} sparse\n\
1956 Uses @code{@var{m} = max (@var{i})}, @code{@var{n} = max (@var{j})}\n\ 1983 matrix and is equivalent to @code{"RSBOI_FNS" ([], [], [], @var{m}, @var{n})}.\n\
1957 \n\ 1984 \n\
1958 @deftypefnx {Loadable Function} {@var{s} =} "RSBOI_FNS" (@var{m}, @var{n})\n\ 1985 \
1959 If @var{m} and @var{n} are integers, equivalent to @code{"RSBOI_FNS" ([], [], [], @var{m}, @var{n}, 0)}\n\
1960 \n\ 1986 \n\
1961 @deftypefnx {Loadable Function} {@var{s} =} "RSBOI_FNS" (\"set\", @var{opn}, @var{opv})\n\ 1987 \
1962 If @var{opn} is a string representing a valid librsb option name and @var{opv} is a string representing a valid librsb option value, the corresponding librsb option will be set to that value.\n\ 1988 If @var{m} or @var{n} are not specified, then @code{@var{m} = max (@var{i})}, @code{@var{n} = max (@var{j})}.\n\
1963 \n\ 1989 \n\
1964 @deftypefnx {Loadable Function} {@var{s} =} "RSBOI_FNS" (@var{A}, \"get\", @var{mif})\n\ 1990 \
1965 If @var{mif} is a string specifying a valid librsb matrix info string (valid for librsb's rsb_mtx_get_info_from_string()), then the corresponding value will be returned for matrix @var{A}. If @var{mif} is the an empty string (\"\"), matrix structure information will be returned.\n\ 1991 If @var{opn} is a string representing a valid librsb option name and @var{opv} is a string representing a valid librsb option value, these will be passed to the @code{rsb_lib_set_opt_str()} function.\n\
1966 \n\ 1992 \n\
1967 @deftypefnx {Loadable Function} {@var{s} =} "RSBOI_FNS" (@var{A}, @var{S})\n\ 1993 \
1968 If @var{A} is a "RSBOI_FNS" matrix and @var{S} is a string, @var{S} will be interpreted as a query string about matrix @var{A}.\n\ 1994 If @var{mif} is a string specifying a valid librsb matrix info string (valid for librsb's @code{rsb_mtx_get_info_from_string()}), then the corresponding value will be returned for matrix @var{A}. If @var{mif} is the an empty string (\"\"), matrix structure information will be returned.\n\
1995 \n\
1996 \
1997 If @var{A} is a "RSBOI_FNS" matrix and @var{QS} is a string, @var{QS} will be interpreted as a query string about matrix @var{A}.\n\
1969 \n"\ 1998 \n"\
1970 /*If any of @var{sv}, @var{i} or @var{j} are scalars, they are expanded\n\ 1999 /*If any of @var{sv}, @var{i} or @var{j} are scalars, they are expanded\n\
1971 to have a common size.\n*/ 2000 to have a common size.\n*/
1972 RSBOI_10100_DOC""\ 2001 RSBOI_10100_DOC""\
1973 "\n\ 2002 "\n\
2080 && args(1).is_string() && args(1).string_value().substr(0,6)=="render" 2109 && args(1).is_string() && args(1).string_value().substr(0,6)=="render"
2081 && args(2).is_string()) 2110 && args(2).is_string())
2082 { 2111 {
2083 rsb_err_t errval = RSB_ERR_NO_ERROR; 2112 rsb_err_t errval = RSB_ERR_NO_ERROR;
2084 std::string rmf = args(2).string_value(); 2113 std::string rmf = args(2).string_value();
2085 rsb_coo_idx_t pmWidth = 512, pmHeight = 512; 2114 rsb_coo_idx_t pmWidth = 512, pmHeight = 512; /* Care to update the documentation when changing these. */
2086 rsb_flags_t marf = RSB_MARF_EPS; 2115 rsb_flags_t marf = RSB_MARF_EPS;
2087 /* may tell the user to supply a sparsersb matrix in case input is not 'sparse' */ 2116 /* may tell the user to supply a sparsersb matrix in case input is not 'sparse' */
2088 2117
2089 if (nargin > 3) pmWidth = args(3).scalar_value(); 2118 if (nargin > 3) pmWidth = args(3).scalar_value();
2090 if (nargin > 4) pmHeight = args(4).scalar_value(); 2119 if (nargin > 4) pmHeight = args(4).scalar_value();