Created
June 10, 2012 19:00
-
-
Save jamesthompson/2906929 to your computer and use it in GitHub Desktop.
Legendre Polynomials
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def leg(mode:Int, angle:Double) : IndexedSeq[Double] = { | |
val cosAngle = math.cos(angle) | |
lazy val stream: Stream[Double] = { | |
def loop(last:Double, curr:Double, k:Double = 0.0) : Stream[Double] = curr #:: loop(curr, ((2 * k + 1) * cosAngle * curr - k * last) / (k + 1), k + 1) | |
loop(0.0, 1.0) | |
} | |
stream.take(mode + 1).toIndexedSeq | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Stream Legendre Polynomials