|
Ublas : |
From: Nico Galoppo (ngaloppo_at_[hidden])
Date: 2008-04-03 11:37:16
Hi,
Here's a little trivia for you advanced ublas users. Often, I write
routines that are identical for all matrix types (either dense or
sparse), except for the final 'solve'. e.g. for dense matrices, I'd
want to use a direct solver, but for sparse matrices, I might prefer
an iterative solver. Anyways, I am looking for a way to have an
automatic dispatcher that looks at whether the input type is a sparse
or dense matrix, and then dispatches to the correctly specialized
solve function. I know of ways to do this with templated traits, but
I'd need some way to 'recognize' a sparse matrix type vs. a dense one,
typically a typedef inside the type declaration should work. This
would require changes to the ublas native matrix types, *unless*
1) there already is some kind of typedef in the native types that
allows us to recognize sparse vs. dense
2) i write my own matrix traits class that I then have to specialize
for each of the ublas native types
Does any of you have some more insight?
--nico
-- Nico Galoppo :: http://www.ngaloppo.org