Beispiel #1
0
def firstElmOneElseZero(vect):
    zerosVect = vector.zeroOfVect(vect)
    if not (vector.isMatrix(vect)):
        zerosVect[0] = 1
        return zerosVect
    zerosVect[0][0] = 1
    return zerosVect
Beispiel #2
0
def firstElmValueElseZero(vect, alphaVect, index):
    if (index > len(alphaVect)):
        raise Exception("Index Error! cannot set fist element value")
    zerosVect = vector.zeroOfVect(vect)
    if not (vector.isMatrix(vect)):
        zerosVect[0] = alphaVect[index]
        return zerosVect
    zerosVect[0][0] = alphaVect[index]
    return zerosVect
Beispiel #3
0
def matrixSliceMarch(vect, index):
    if (index >= len(vect)):
        raise Exception(
            "\n >> Error! Invalid index \n >> vectorLength:%s \n >> index:%s "
            % (len(vect), index))
    vectSubA = vect[:index]
    vectSubB = vect[index:]
    vectA = []
    if (len(vectSubA) > 0):
        vectA = vector.zeroOfVect(vectSubA)
    vectB = firstElmOneElseZero(vectSubB)
    return vectA + vectB
def setSutmColumnValue(vect, index):
    if(index >= len(vect)):
        raise Exception(
            "\n >> Error! Invalid index \n >> vectorLength:%s \n >> index:%s " % (len(vect), index))
    vectSubA = vect[:index]
    vectSubB = vect[index:]
    vectA = []
    vectB = []
    # Becuase at first iteration vectSubA will be empty array
    if(len(vectSubA) > 0):
        vectA = vectSubA
    vectB = vector.zeroOfVect(vectSubB)
    return vectA+vectB
Beispiel #5
0
def setColumnToDiagnolValue(vect, alphaVect, index):
    if (index >= len(vect)):
        raise Exception(
            "\n >> Error! Invalid index \n >> vectorLength:%s \n >> index:%s "
            % (len(vect), index))
    vectSubA = vect[:index]
    vectSubB = vect[index:]
    vectA = []
    vectB = []
    if (len(vectSubA) > 0):
        vectA = vector.zeroOfVect(vectSubA)
    if (index < len(alphaVect)):
        vectB = firstElmValueElseZero(vectSubB, alphaVect, index)
    return vectA + vectB
def firstRemainElseZero(vect):
    a1 = vect[0]
    resultvect = vector.zeroOfVect(vect)
    resultvect[0] = a1
    return resultvect
def firstOneElseZero(vect):
    resultvect = vector.zeroOfVect(vect)
    resultvect[0] = 1
    return resultvect