*/
class SparseMatrixStruct
{
- private:
- /**
- * Copy constructor, made private in order to
- * prevent copying such an object which does
- * not make much sense because you can use
- * a structure like this for more than one
- * matrix.
- *
- * Because it is not needed, this function
- * is not implemented.
- */
- SparseMatrixStruct (const SparseMatrixStruct &);
-
public:
/**
* Initialize the matrix empty, i.e. with
*/
SparseMatrixStruct ();
+ /**
+ * Copy constructor. This constructor is
+ * only allowed to be called if the matrix
+ * structure to be copied is empty. This is
+ * so in order to prevent involuntary
+ * copies of objects for temporaries, which
+ * can use large amounts of computing time.
+ * However, copy constructors are needed
+ * if yo want to use the STL data types
+ * on classes like this, e.g. to write
+ * such statements like
+ * #v.push_back (SparseMatrixStruct());#,
+ * with #v# a vector of #SparseMatrixStruct#
+ * objects.
+ *
+ * Usually, it is sufficient to use the
+ * explicit keyword to disallow unwanted
+ * temporaries, but for the STL vectors,
+ * this does not work. Since copying a
+ * structure like this is not useful
+ * anyway because multiple matrices can
+ * use the same sparsity structure, copies
+ * are only allowed for empty objects, as
+ * described above.
+ */
+ SparseMatrixStruct (const SparseMatrixStruct &);
+
/**
* Initialize a rectangular matrix with
* #m# rows and #n# columns,
* Exception
*/
DeclException0 (ExcIO);
+ /**
+ * Exception
+ */
+ DeclException0 (ExcInvalidConstructorCall);
private:
unsigned int max_dim;
* #reinit(SparseMatrixStruct)#.
*/
SparseMatrix ();
+
+ /**
+ * Copy constructor. This constructor is
+ * only allowed to be called if the matrix
+ * to be copied is empty. This is for the
+ * same reason as for the
+ * #SparseMatrixStruct#, see there for the
+ * details.
+ *
+ * If you really want to copy a whole
+ * matrix, you can do so by using the
+ * #copy_from# function.
+ */
+ SparseMatrix (const SparseMatrix &);
+
/**
* Constructor. Takes the given matrix
* Exception
*/
DeclException0 (ExcIO);
+ /**
+ * Exception
+ */
+ DeclException0 (ExcInvalidConstructorCall);
private:
const SparseMatrixStruct * cols;
+SparseMatrixStruct::SparseMatrixStruct (const SparseMatrixStruct &s) :
+ max_dim(0),
+ max_vec_len(0),
+ rowstart(0),
+ colnums(0)
+{
+ Assert (s.rowstart == 0, ExcInvalidConstructorCall());
+ Assert (s.colnums == 0, ExcInvalidConstructorCall());
+ Assert (s.rows == 0, ExcInvalidConstructorCall());
+ Assert (s.cols == 0, ExcInvalidConstructorCall());
+
+ reinit (0,0,0);
+};
+
+
+
SparseMatrixStruct::SparseMatrixStruct (const unsigned int m, const unsigned int n,
const unsigned int max_per_row)
: max_dim(0),
void
-SparseMatrixStruct::reinit (const unsigned int m, const unsigned int n,
+SparseMatrixStruct::reinit (const unsigned int m,
+ const unsigned int n,
const unsigned int max_per_row)
{
Assert ((max_per_row>0) || ((m==0) && (n==0)), ExcInvalidNumber(max_per_row));