anantguptadbl:

# POLYVAL in PYTORCH
coeffs=torch.FloatTensor([1.,2.,1.,1.])
x=torch.FloatTensor([3.0])

def getPolyVal(x,coeffs):
    curVal=0
    for curValIndex in range(len(coeffs)-1):
        curVal=(curVal+coeffs[curValIndex])*x[0]
    return(curVal+coeffs[len(coeffs)-1])

getPolyVal(x,coeffs)



Thanks.
Any tricks I can do to make this as fast as possible?