Skip to content

Commit

Permalink
Initialize a const static as such.
Browse files Browse the repository at this point in the history
  • Loading branch information
ktf committed Nov 13, 2013
1 parent f4b04d8 commit ca050b1
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions DataFormats/CSCRecHit/src/CSCSegment.cc
Expand Up @@ -67,17 +67,19 @@ AlgebraicVector CSCSegment::parameters() const {
return result;
}

AlgebraicMatrix createStaticMatrix()
{
AlgebraicMatrix m( 4, 5, 0);
m[0][1] = 1;
m[1][2] = 1;
m[2][3] = 1;
m[3][4] = 1;
return m;
}

static const AlgebraicMatrix theProjectionMatrix = createStaticMatrix();

AlgebraicMatrix CSCSegment::projectionMatrix() const {
static AlgebraicMatrix theProjectionMatrix( 4, 5, 0);
static bool isInitialized = false;
if (!isInitialized) {
theProjectionMatrix[0][1] = 1;
theProjectionMatrix[1][2] = 1;
theProjectionMatrix[2][3] = 1;
theProjectionMatrix[3][4] = 1;
isInitialized=true;
}
return theProjectionMatrix;
}

Expand Down

0 comments on commit ca050b1

Please sign in to comment.