Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Quasicrystal

 `1 import JSci.maths.*;2 import JSci.maths.matrices.DoubleTridiagonalMatrix;3 import JSci.io.*;4 import java.io.*;5 6 /**7 * Phonons in a Quasicrystal8 * @author Mark Hale9 */10 public final class Quasicrystal {11     private int N;12         private double mass_m,mass_M;13     private double eigenvalue[];14     /**15     * Instantiate class.16     */17     public static void main(String arg[]) {18         if(arg.length==3) {19             int n=Integer.valueOf(arg[0]).intValue();20             double m1=Double.valueOf(arg[1]).doubleValue();21             double m2=Double.valueOf(arg[2]).doubleValue();22             new Quasicrystal(n,m1,m2);23         } else {24             System.out.println("Need to specify command line arguments:");25             System.out.println(" ");26                 }27     }28     /**29     * Constructor.30     * @param n order of matrix31     * @param m1 mass32     * @param m2 mass33     */34     public Quasicrystal(int n,double m1,double m2) {35         N=n;36                 mass_M=m1;37                 mass_m=m2;38                 compute();39         saveResults();40     }41     /**42     * Calculate the vibrational frequencies.43     */44     private void compute() {45         DoubleTridiagonalMatrix matrix=new DoubleTridiagonalMatrix(N);46         eigenvalue=new double[N];47 // Generate sequence of masses m and M48 double mass[]=fibonacci();49 // Create matrix50 matrix.setElement(0,0,2.0/mass[0]);51         matrix.setElement(0,1,-1.0/Math.sqrt(mass[0]*mass[1]));52         for(int i=1;i