Guest User

Untitled

a guest
May 25th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. def linearInterpolation(weights: Seq[Double], points: Seq[Seq[Double]]) : Seq[T] = {
  2.  
  3. weights.zip(points).map(
  4. weight_point => weight_point._2.map(coordinate => weight_point._1 * coordinate)
  5. ).reduce((point_a : Seq[Double], point_b : Seq[Double]) => point_a.zip(point_b).map(coordinate_points => (coordinate_points._1 + coordinate_points._2).asInstanceOf[T]))
  6.  
  7. }
  8.  
  9. def linearInterpolation(weights: Seq[Double], points: Seq[Seq[Double]])(fromDouble: Double => T) : Seq[T] = {
  10.  
  11. weights.zip(points).map(
  12. weight_point => weight_point._2.map(coordinate => weight_point._1 * coordinate)
  13. ).reduce((point_a : Seq[Double], point_b : Seq[Double]) => point_a.zip(point_b).map(coordinate_points => coordinate_points._1 + coordinate_points._2)).map(fromDouble)
  14.  
  15. }
Add Comment
Please, Sign In to add comment