Created named constructor for identity matrices

This commit is contained in:
babrodtk
2015-09-21 09:20:28 +02:00
parent 4073abeafb
commit 7f9175e046
2 changed files with 21 additions and 24 deletions

View File

@@ -74,16 +74,13 @@ namespace Opm
enum CreationType { ZeroMatrix, IdentityMatrix };
AutoDiffMatrix(const CreationType t, const int num_rows)
: type_(t == ZeroMatrix ? Zero : Identity),
rows_(num_rows),
cols_(num_rows),
diag_(),
sparse_()
/**
* Creates an identity matrix with num_rows_cols x num_rows_cols entries
*/
static AutoDiffMatrix createIdentity(const int num_rows_cols)
{
return AutoDiffMatrix(Identity, num_rows_cols, num_rows_cols);
}