Ignore:
Timestamp:
11/18/11 19:55:02 (8 years ago)
Author:
aivar
Message:

Got rid of the idea of creating an ICurveFitter for each fit type (i.e. RLD, LMA, RLD_LMA).

Location:
trunk/projects/curve-fitter/src/main/java/loci/curvefitter
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/projects/curve-fitter/src/main/java/loci/curvefitter/AbstractCurveFitter.java

    r7673 r7810  
    4141 */ 
    4242public abstract class AbstractCurveFitter implements ICurveFitter { 
     43    FitAlgorithm m_fitAlgorithm; 
    4344    FitFunction m_fitFunction; 
    4445    double m_xInc = ICurveFitter.DEFAULT_X_INC; 
    4546    boolean[] m_free; 
    4647    double[] m_instrumentResponse; 
     48     
     49    @Override 
     50    public FitAlgorithm getFitAlgorithm() { 
     51        return m_fitAlgorithm; 
     52    } 
     53     
     54    @Override 
     55    public void setFitAlgorithm(FitAlgorithm algorithm) { 
     56        m_fitAlgorithm = algorithm; 
     57    } 
    4758     
    4859    @Override 
  • trunk/projects/curve-fitter/src/main/java/loci/curvefitter/CurveFitData.java

    r7673 r7810  
    5353    double[] m_sig; 
    5454    double[] m_yFitted; 
     55    double m_chiSquareTarget; 
    5556    double m_chiSquare; 
    5657    Object m_userData; 
     
    136137    } 
    137138 
     139    @Override 
     140    public double getChiSquareTarget() { 
     141        return m_chiSquareTarget; 
     142    } 
     143 
     144    @Override 
     145    public void setChiSquareTarget(double chiSquareTarget) { 
     146        m_chiSquareTarget = chiSquareTarget; 
     147    } 
     148     
     149    @Override 
    138150    public double getChiSquare() { 
    139151        return m_chiSquare; 
    140152    } 
    141153 
     154    @Override 
    142155    public void setChiSquare(double chiSquare) { 
    143156        m_chiSquare = chiSquare; 
  • trunk/projects/curve-fitter/src/main/java/loci/curvefitter/GrayCurveFitter.java

    r7668 r7810  
    8181    } 
    8282 
    83     public GrayCurveFitter(int algType) { 
    84         m_algType = algType; 
    85     } 
    86  
    87     public GrayCurveFitter() { 
    88         m_algType = 0; 
    89     } 
    90  
    9183    @Override 
    9284    public int fitData(ICurveFitData[] dataArray, int start, int stop) { 
     
    9890        //TODO ARG August use initial X of 0. 
    9991 
    100         if (0 == m_algType) { 
     92        if (FitAlgorithm.RLD.equals(m_fitAlgorithm)) { 
    10193            float xincr = (float) m_xInc; 
    10294            int fitStart = start; 
  • trunk/projects/curve-fitter/src/main/java/loci/curvefitter/GrayNRCurveFitter.java

    r7668 r7810  
    120120    } 
    121121 
    122     public GrayNRCurveFitter(int algType) { 
    123         m_algType = algType; 
    124     } 
    125  
    126     public GrayNRCurveFitter() { 
    127         m_algType = 0; 
    128     } 
    129  
    130122 
    131123    @Override 
     
    160152        } 
    161153 
    162         if (0 == m_algType) { //TODO crude; use enums 
     154        if (FitAlgorithm.RLD.equals(m_fitAlgorithm)) { 
    163155            // RLD or triple integral fit 
    164156            DoubleByReference z = new DoubleByReference(); 
  • trunk/projects/curve-fitter/src/main/java/loci/curvefitter/ICurveFitData.java

    r7673 r7810  
    158158     */ 
    159159    public void setYFitted(double yFit[]); 
     160 
     161    /** 
     162     * Gets chi square target. 
     163     *  
     164     * @return targetted chisquare 
     165     */ 
     166    public double getChiSquareTarget(); 
     167     
     168    /** 
     169     * Sets chi square target 
     170     *  
     171     * @param chiSquare targetted chi square 
     172     */ 
     173    public void setChiSquareTarget(double chiSquareTarget); 
     174     
     175 
     176    /** 
     177     * Gets fitted chi square. 
     178     *  
     179     * @return fitted chisquare 
     180     */ 
     181    public double getChiSquare(); 
     182     
     183    /** 
     184     * Sets fitted chi square 
     185     *  
     186     * @param chiSquare fitted chi square 
     187     */ 
     188    public void setChiSquare(double chiSquare); 
    160189} 
  • trunk/projects/curve-fitter/src/main/java/loci/curvefitter/ICurveFitter.java

    r7673 r7810  
    4141 */ 
    4242public interface ICurveFitter { 
    43  
     43     
     44    /** 
     45     * Specifies fitting algorithm. 
     46     */ 
     47    public enum FitAlgorithm { 
     48        RLD, LMA, RLD_LMA 
     49    } 
     50     
    4451    /** 
    4552     * Specifies curves that this fits. 
     
    5360     */ 
    5461    public double DEFAULT_X_INC = 1.0f; 
     62     
     63    /** 
     64     * Get fitting algorithm. 
     65     *  
     66     * @return fitting algorithm 
     67     */ 
     68    public FitAlgorithm getFitAlgorithm(); 
     69     
     70    /** 
     71     * Set fitting algorithm. 
     72     *  
     73     * @param fitting algorithm 
     74     */ 
     75    public void setFitAlgorithm(FitAlgorithm algorithm); 
    5576 
    5677    /** 
     
    132153     * @return status code 
    133154     */ 
    134     public int fitData(ICurveFitData[] data, int start, int stop); 
     155    public int fitData(ICurveFitData[] data, int start, int stop);  
    135156} 
  • trunk/projects/curve-fitter/src/main/java/loci/curvefitter/SLIMCurveFitter.java

    r7700 r7810  
    5555 */ 
    5656public class SLIMCurveFitter extends AbstractCurveFitter { 
    57     public enum AlgorithmType { RLD, LMA, RLD_LMA }; 
    58  
    5957    private static boolean s_libraryLoaded = false; 
    6058    private static boolean s_libraryOnPath = false; 
    6159    private static CLibrary s_library; 
    62  
    63     private AlgorithmType m_algorithmType; 
    6460 
    6561    /** 
     
    182178                           ); 
    183179 
    184     /** 
    185      * Create a curve fitter for a given algorithm type. 
    186      * 
    187      * @param algorithmType 
    188      */ 
    189     public SLIMCurveFitter(AlgorithmType algorithmType) { 
    190         m_algorithmType = algorithmType; 
    191     } 
    192  
    193     /** 
    194      * Create the default curve fitter, which uses RLD. 
    195      * 
    196      */ 
    197     public SLIMCurveFitter() { 
    198         m_algorithmType = AlgorithmType.RLD; 
    199     } 
    200  
    201  
    202180    @Override 
    203181    public int fitData(ICurveFitData[] dataArray, int start, int stop) { 
     
    239217 
    240218        boolean[] free = m_free.clone(); 
    241         if (AlgorithmType.RLD.equals(m_algorithmType)) { 
     219        if (FitAlgorithm.RLD.equals(m_fitAlgorithm)) { 
    242220            // pure RLD (versus RLD followed by LMA) has no way to fix 
    243221            // parameters 
     
    251229            DoubleByReference chiSquare = new DoubleByReference(); 
    252230            double chiSquareTarget = 1.0; //TODO s/b specified incoming 
    253  
    254             if (AlgorithmType.RLD.equals(m_algorithmType) || AlgorithmType.RLD_LMA.equals(m_algorithmType)) { 
     231             
     232            if (FitAlgorithm.RLD.equals(m_fitAlgorithm) || FitAlgorithm.RLD_LMA.equals(m_fitAlgorithm)) { 
    255233                // RLD or triple integral fit 
    256234                DoubleByReference z = new DoubleByReference(); 
     
    299277                } 
    300278            } 
    301  
    302             if (AlgorithmType.LMA.equals(m_algorithmType) || AlgorithmType.RLD_LMA.equals(m_algorithmType)) { 
     279             
     280            if (FitAlgorithm.LMA.equals(m_fitAlgorithm) || FitAlgorithm.RLD_LMA.equals(m_fitAlgorithm)) { 
    303281                // LMA fit 
    304282                for (ICurveFitData data: dataArray) { 
     
    331309            double[] chiSquare = new double[1]; 
    332310            double chiSquareTarget = 1.0; //TODO s/b specified incoming 
    333  
    334             if (AlgorithmType.RLD.equals(m_algorithmType) || AlgorithmType.RLD_LMA.equals(m_algorithmType)) { 
     311             
     312            if (FitAlgorithm.RLD.equals(m_fitAlgorithm) || FitAlgorithm.RLD_LMA.equals(m_fitAlgorithm)) { 
    335313                // RLD or triple integral fit 
    336314 
     
    382360            } 
    383361 
    384             if (AlgorithmType.LMA.equals(m_algorithmType) || AlgorithmType.RLD_LMA.equals(m_algorithmType)) { 
     362            if (FitAlgorithm.LMA.equals(m_fitAlgorithm) || FitAlgorithm.RLD_LMA.equals(m_fitAlgorithm)) { 
    385363                // LMA fit 
    386364                for (ICurveFitData data: dataArray) { 
Note: See TracChangeset for help on using the changeset viewer.