fatalaa

LagrangeInterpolation

Apr 10th, 2012
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. /**
  7.  *
  8.  * @author Tibi
  9.  */
  10. import java.util.*;
  11.  
  12. public class LagrangeInterpolacio extends IllesztettFuggveny {
  13.    
  14.     LagrangeInterpolacio() {
  15.         super();
  16.     }
  17.    
  18.     LagrangeInterpolacio( LagrangeInterpolacio obj ) {
  19.         super( obj );
  20.     }
  21.    
  22.     LagrangeInterpolacio( AdatParok ap ) {
  23.        
  24.     }
  25.    
  26.     float ertek( float ertek , AdatParok obj ) {
  27.         float fx = 0;
  28.         for( int i = 0; i < obj.size(); i++ ) {
  29.             float Lg = 1;
  30.             for( int j = 0; j < obj.size(); j++ ) {
  31.                 if( i != j ) {
  32.                     Lg *= ( ertek - obj.getAdatPar( j ).x ) /
  33.                           ( obj.getAdatPar( i ).x - obj.getAdatPar( j ).x );
  34.                 }
  35.             }
  36.             fx += Lg * obj.getAdatPar( i ).y;
  37.         }
  38.         return fx;
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment