changeset 12538:76d554668a8f octave-forge

the autotune case will accept an optional output argument (to be used for the tuned matrix).
author michelemartone
date Sat, 18 Oct 2014 15:26:31 +0000
parents b644dc25de64
children b8f0148a86f1
files main/sparsersb/doc/sparsersb.txt main/sparsersb/src/sparsersb.cc
diffstat 2 files changed, 16 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/main/sparsersb/doc/sparsersb.txt	Sat Oct 18 13:36:37 2014 +0000
+++ b/main/sparsersb/doc/sparsersb.txt	Sat Oct 18 15:26:31 2014 +0000
@@ -64,11 +64,13 @@
      rendered as an Encapsulated Postcript file FILENAME. Optionally,
      width and height can be specified. Defaults are 512.
 
- -- Loadable Function: S = sparsersb (A,"autotune"[, TRANSA, NRHS,
+ -- Loadable Function: [O =] sparsersb (A,"autotune"[, TRANSA, NRHS,
           MAXR, TMAX, TN, SF])
      If A is a sparsersb matrix, autotuning of the matrix will take
-     place, with SpMV and autotuning parameters. After "autotune", the
-     remaining parameters are optional.
+     place, with SpMV and autotuning parameters. After the "autotune"
+     string, the remaining parameters are optional. If giving an output
+     argument O, that will be assigned to the autotuned matrix, and the
+     input one A will remain unchanged.
 
      Please note that on `sparsersb' type variables are available most,
      but not all of the operators available for `full' or `sparse'
--- a/main/sparsersb/src/sparsersb.cc	Sat Oct 18 13:36:37 2014 +0000
+++ b/main/sparsersb/src/sparsersb.cc	Sat Oct 18 15:26:31 2014 +0000
@@ -219,8 +219,8 @@
 #define RSBOI_10100_DOC \
 "@deftypefnx {Loadable Function} {@var{s} =} "RSBOI_FNS" (@var{A},\"render\", @var{filename}[, @var{rWidth}, @var{rHeight}])\n"\
 "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"\
-"@deftypefnx {Loadable Function} {@var{s} =} "RSBOI_FNS" (@var{A},\"autotune\"[, @var{transA}, @var{nrhs}, @var{maxr}, @var{tmax}, @var{tn}, @var{sf}])\n"\
-"If @var{A} is a "RSBOI_FNS" matrix, autotuning of the matrix will take place, with SpMV and autotuning parameters. After \"autotune\", the remaining parameters are optional.\n"
+"@deftypefnx {Loadable Function} {[@var{O} =]} "RSBOI_FNS" (@var{A},\"autotune\"[, @var{transA}, @var{nrhs}, @var{maxr}, @var{tmax}, @var{tn}, @var{sf}])\n"\
+"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"
 #else
 #define RSBOI_10100_DOC	""
 #endif
@@ -2052,7 +2052,15 @@
 		// ...
 		if(!osmp || !osmp->mtxAp)
 			goto ret;/* FIXME: error handling missing here */
-		errval = rsb_tune_spmm(&osmp->mtxAp,&sf,&tn,maxr,tmax,transA,alphap,NULL/*osmp->mtxAp*/,nrhs,order,Bp,ldB,betap,Cp,ldC);
+		if(nargout)
+		{
+			struct rsb_mtx_t*mtxAp = NULL;
+			errval = rsb_mtx_clone(&mtxAp,RSB_NUMERICAL_TYPE_SAME_TYPE,RSB_TRANSPOSITION_N,NULL,osmp->mtxAp,RSBOI_EXPF);
+			errval = rsb_tune_spmm(&mtxAp,&sf,&tn,maxr,tmax,transA,alphap,NULL,nrhs,order,Bp,ldB,betap,Cp,ldC);
+			retval.append(new octave_sparsersb_mtx(mtxAp));
+		}
+		else
+			errval = rsb_tune_spmm(&osmp->mtxAp,&sf,&tn,maxr,tmax,transA,alphap,NULL/*osmp->mtxAp*/,nrhs,order,Bp,ldB,betap,Cp,ldC);
 		/* FIXME: serious error handling missing here */
 		goto ret;
 	}