@@ -42,6 +42,7 @@ using namespace SCIRun::Core::Algorithms::Math;
4242
4343ALGORITHM_PARAMETER_DEF (Math, IsSliceColumn);
4444ALGORITHM_PARAMETER_DEF (Math, SliceIndex);
45+ ALGORITHM_PARAMETER_DEF (Math, MaxIndex);
4546ALGORITHM_PARAMETER_DEF (Math, PlayMode);
4647
4748GetMatrixSliceAlgo::GetMatrixSliceAlgo ()
@@ -57,43 +58,46 @@ AlgorithmOutput GetMatrixSliceAlgo::run_generic(const AlgorithmInput& input) con
5758 auto outputMatrix = runImpl (inputMatrix, get (Parameters::SliceIndex).toInt (), get (Parameters::IsSliceColumn).toBool ());
5859
5960 AlgorithmOutput output;
60- output[Variables::OutputMatrix] = outputMatrix;
61+ output[Variables::OutputMatrix] = outputMatrix.get <0 >();
62+ output.setAdditionalAlgoOutput (boost::make_shared<Variable>(Name (" maxIndex" ), outputMatrix.get <1 >()));
6163
6264 return output;
6365}
6466
65- MatrixHandle GetMatrixSliceAlgo::runImpl (MatrixHandle matrix, int index, bool getColumn) const
67+ boost::tuple< MatrixHandle, int > GetMatrixSliceAlgo::runImpl (MatrixHandle matrix, int index, bool getColumn) const
6668{
6769 ENSURE_ALGORITHM_INPUT_NOT_NULL (matrix, " Input matrix" );
6870 if (getColumn)
6971 {
7072 checkIndex (index, matrix->ncols ());
73+ auto max = matrix->ncols () - 1 ;
7174
7275 // dense case only now
7376 auto dense = matrix_cast::as_dense (matrix);
7477 if (dense)
75- return boost::make_shared<DenseMatrix>(dense->col (index));
78+ return boost::make_tuple (boost:: make_shared<DenseMatrix>(dense->col (index)), max );
7679 else
7780 {
7881 auto sparse = matrix_cast::as_sparse (matrix);
7982 if (sparse)
80- return boost::make_shared<SparseRowMatrix>(sparse->col (index));
83+ return boost::make_tuple (boost:: make_shared<SparseRowMatrix>(sparse->col (index)), max );
8184 return nullptr ;
8285 }
8386 }
8487 else
8588 {
8689 checkIndex (index, matrix->nrows ());
90+ auto max = matrix->nrows () - 1 ;
8791
8892 // dense case only now
8993 auto dense = matrix_cast::as_dense (matrix);
9094 if (dense)
91- return boost::make_shared<DenseMatrix>(dense->row (index));
95+ return boost::make_tuple (boost:: make_shared<DenseMatrix>(dense->row (index)), max );
9296 else
9397 {
9498 auto sparse = matrix_cast::as_sparse (matrix);
9599 if (sparse)
96- return boost::make_shared<SparseRowMatrix>(sparse->row (index));
100+ return boost::make_tuple (boost:: make_shared<SparseRowMatrix>(sparse->row (index)), max );
97101 return nullptr ;
98102 }
99103 }
0 commit comments