Example usage for org.apache.commons.math3.linear BlockRealMatrix getColumnDimension

List of usage examples for org.apache.commons.math3.linear BlockRealMatrix getColumnDimension

Introduction

In this page you can find the example usage for org.apache.commons.math3.linear BlockRealMatrix getColumnDimension.

Prototype

@Override
public int getColumnDimension() 

Source Link

Usage

From source file:gamlss.smoothing.PB.java

/**
 * Constructs the base and penalty matrices and also sets a
 *  value for degree of freedom.//from  w w  w.  j a v a 2  s  .  c  o m
 * @param colValues - values of certain column (colNumber) of
 *  the smooth matrix of the fitting distribution parameter 
 * @param df - degree of freedom
 * @param colNumber - number of the supplied column (colValues)
 *  of the fitting distribution parameter
 */
//pb<-function(x, df = NULL, lambda = NULL, control=pb.control(...), ...)
private void buildMatrices(final ArrayRealVector colValues, Integer df, final int colNumber) {
    //X <- bbase(x, xmin, xmax, control$inter, control$degree,
    //control$quantiles) # create the basis
    BlockRealMatrix xM = formX(colValues);

    //D <- if(control$order==0) diag(r) else diff(diag(r),
    //diff=control$order) # the penalty matrix
    BlockRealMatrix dM = formD(xM);

    //if(!is.null(df)) # degrees of freedom
    if (df != null) {
        //if (df>(dim(X)[2]-2))
        if (df > xM.getColumnDimension() - 2) {
            //df <- 3;
            df = 3;

            //warning("The df's exceed the 
            //number of columns of the design
            //matrix", "\n",  "   they are set to 3") 
            System.err.println(
                    "The df's exceed the number of columns " + " of the design matrix, they are set to 3");
        }
        if (df < 0) {
            //if (df < 0)  warning("the extra df's are set to 0") 
            //df <- if (df < 0)  2  else  df+2
            System.err.println("the extra df's are set to 2");
            df = 2;
        } else {
            df = df + 2;
        }
    }
    baseMatrices.put(colNumber, xM);
    penaltyMatrices.put(colNumber, dM);
    dfValues.put(colNumber, df);
}