Skip to content

Commit

Permalink
updated addElement to use tril symmetric matricies
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesdaniels committed Dec 10, 2015
1 parent abdc430 commit 04fdb5b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/python33/libHercMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,19 @@ def getInFormat(this, form):
#
# @param element anything supported by
# libHercMatrix.hercMatrix.castElement()
# @param extrapolate if `True`, elements which would fall in the upper
# triangle of a sparse matrix will be transposed into the lower triangle.
# This is the default behavior.
#
# @exception ValueError element could not be cast by castElement()

def addElement(this, element):
def addElement(this, element, extrapolate = True):
# element can be any element supported by this.castElement()

try:
element = this.castElement(element)
if this.symmetry == 'SYM':
if element['row'] > element['col']:
if (this.symmetry == 'SYM') and extrapolate:
if element['row'] < element['col']:
# put element in the top triangle, this matrix is
# symmetric!
temp = numpy.array(this.dtype)
Expand Down Expand Up @@ -274,8 +277,8 @@ def removeElement(this, n, rtol=0, atol=0):
#
# @returns float with the value at the specified row, col

def getValue(this, row, col, extrapolate = False):
if this.symmetry == 'SYM':
def getValue(this, row, col, extrapolate = True):
if (this.symmetry == 'SYM') and extrapolate:
if row < col:
# extrapolate for values in upper triangle
tempRow = row
Expand Down

0 comments on commit 04fdb5b

Please sign in to comment.