CPD Results
The following document contains the results of PMD's CPD 7.14.0.
Duplications
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/DenseDoubleMatrix.java | 243 |
| ubic/basecode/dataStructure/matrix/SparseDoubleMatrix.java | 232 |
if ( i == startRow ) {
C colName = this.getColName( j );
returnval.setColumnName( colName, j );
}
returnval.set( k, j, this.get( i, j ) );
}
k++;
}
return returnval;
}
@Override
public boolean isMissing( int i, int j ) {
return Double.isNaN( get( i, j ) );
}
@Override
public int rows() {
return matrix.rows();
}
@Override
public void set( int row, int column, Double value ) {
matrix.set( row, column, value );
}
/**
* @return int
* @see AbstractMatrix2D#size()
*/
@Override
public int size() {
return matrix.size();
}
/*
* (non-Javadoc)
*
* @see ubic.basecode.dataStructure.matrix.DoubleMatrix#subsetColumns(java.util.List)
*/
@Override
public DoubleMatrix<R, C> subsetColumns( List<C> columns ) {
DoubleMatrix<R, C> returnval = new DenseDoubleMatrix<R, C>( this.rows(), columns.size() );
returnval.setRowNames( this.getRowNames() );
for ( int i = 0; i < this.rows(); i++ ) {
int currentColumn = 0;
for ( C c : columns ) {
int j = this.getColIndexByName( c );
returnval.set( i, currentColumn, this.get( i, j ) );
if ( i == 0 ) {
returnval.setColumnName( c, currentColumn );
}
currentColumn++;
}
}
return returnval;
}
@Override
public DoubleMatrix<R, C> subsetRows( List<R> rowNames ) {
DoubleMatrix<R, C> returnval = new DenseDoubleMatrix<R, C>( rowNames.size(), this.columns() ); | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/DenseDoubleMatrix.java | 142 |
| ubic/basecode/dataStructure/matrix/SparseDoubleMatrix.java | 148 |
if ( rowName != null ) returnval.addRowName( rowName );
}
returnval.set( j, k, this.get( j, i ) );
}
k++;
}
return returnval;
}
/*
* (non-Javadoc)
*
* @see basecode.dataStructure.matrix.DoubleMatrixNamed#getColumn(int)
*/
@Override
public double[] getColumn( int col ) {
double[] result = new double[rows()];
for ( int i = 0; i < rows(); i++ ) {
result[i] = get( i, col );
}
return result;
}
/**
* Converts to a String that can be read by read.table in R, using default parameters
*
* @return java.lang.String
*/
/*
* public String toRReadTableString() { Format nf = new Format( "%.4g" ); StringBuffer result = new StringBuffer(
* this.rows() * this.columns() ); if ( this.hasColNames() ) { for ( int i = 0; i < this.columns(); i++ ) {
* result.append( "\"" + this.getColName( i ) +"\" "); System.out.println("\"" + this.getColName( i ) +"\" "); }
* result.append( "\n" ); } for ( int i = 0; i < this.rows(); i++ ) { if ( this.hasRowNames() ) { result.append("\""
* + this.getRowName( i ) + "\"" ); } for ( int j = 0; j < this.columns(); j++ ) { if ( Double.isNaN( this.get( i, j
* ) ) ) { result.append( " NA" ); } else { result.append( " " + nf.format( this.get( i, j ) ) ); } } result.append(
* "\n" ); } return result.toString(); }
*/
@Override
public Double getObject( int row, int col ) {
return new Double( get( row, col ) );
}
/**
* Return a reference to a specific row.
*
* @param row int
* @return double[]
*/
@Override
public double[] getRow( int row ) {
return viewRow( row ).toArray();
}
/*
* (non-Javadoc)
*
* @see basecode.dataStructure.matrix.AbstractNamedDoubleMatrix#getRowArrayList(int)
*/
@Override
public DoubleArrayList getRowArrayList( int i ) {
return new DoubleArrayList( getRow( i ) );
}
/**
* Return a reference to a specific row.
*
* @param s String
* @return double[]
*/
@Override
public double[] getRowByName( R s ) {
return getRow( getRowIndexByName( s ) );
}
@Override
public Double[] getRowObj( int row ) {
Double[] result = new Double[columns()];
for ( int i = 0; i < columns(); i++ ) {
result[i] = new Double( get( row, i ) );
}
return result;
}
/*
* (non-Javadoc)
*
* @see ubic.basecode.dataStructure.matrix.Matrix2D#getRowRange(int, int)
*/
@Override
public DoubleMatrix<R, C> getRowRange( int startRow, int endRow ) {
super.checkRowRange( startRow, endRow );
DoubleMatrix<R, C> returnval = new DenseDoubleMatrix<R, C>( 1 + endRow - startRow, this.columns() ); | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/CompressedSparseDoubleMatrix.java | 103 |
| ubic/basecode/dataStructure/matrix/SparseDoubleMatrix.java | 100 |
DoubleMatrix<R, C> returnval = new CompressedSparseDoubleMatrix<R, C>( this.rows(), this.columns() );
for ( int i = 0; i < this.rows(); i++ ) {
returnval.setRowName( this.getRowName( i ), i );
for ( int j = 0; j < this.columns(); j++ ) {
if ( i == 0 ) {
returnval.setColumnName( this.getColName( j ), j );
}
returnval.set( i, j, this.get( i, j ) );
}
}
return returnval;
}
/**
* @param row
* @param column
* @return
*/
@Override
public double get( int row, int column ) {
return matrix.get( row, column );
}
/*
* (non-Javadoc)
*
* @see ubic.basecode.dataStructure.matrix.NamedPrimitiveMatrix#getColObj(int)
*/
@Override
public Double[] getColObj( int col ) {
Double[] result = new Double[rows()];
for ( int i = 0; i < rows(); i++ ) {
result[i] = new Double( get( i, col ) );
}
return result;
}
@Override
public DoubleMatrix<R, C> getColRange( int startCol, int endCol ) {
super.checkColRange( startCol, endCol );
DoubleMatrix<R, C> returnval = new CompressedSparseDoubleMatrix<R, C>( this.rows(), 1 + endCol - startCol ); | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/CompressedSparseDoubleMatrix.java | 146 |
| ubic/basecode/dataStructure/matrix/SparseDoubleMatrix.java | 138 |
DoubleMatrix<R, C> returnval = new CompressedSparseDoubleMatrix<R, C>( this.rows(), 1 + endCol - startCol );
int k = 0;
for ( int i = startCol; i <= endCol; i++ ) {
C colName = this.getColName( i );
if ( colName != null ) {
returnval.setColumnName( colName, i );
}
for ( int j = 0, m = this.rows(); j < m; j++ ) {
if ( i == startCol ) {
R rowName = this.getRowName( j );
returnval.setRowName( rowName, j );
}
returnval.set( j, k, this.get( j, i ) );
}
k++;
}
return returnval;
}
/*
* (non-Javadoc)
*
* @see basecode.dataStructure.matrix.DoubleMatrixNamed#getColumn(int)
*/
@Override
public double[] getColumn( int col ) {
double[] result = new double[rows()];
for ( int i = 0; i < rows(); i++ ) {
result[i] = get( i, col );
}
return result;
}
@Override
public Double getObject( int row, int col ) {
return new Double( get( row, col ) );
}
/**
* Return a reference to a specific row.
*
* @param row int
* @return double[]
*/
@Override
public double[] getRow( int row ) { | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/CompressedSparseDoubleMatrix.java | 146 |
| ubic/basecode/dataStructure/matrix/FastRowAccessDoubleMatrix.java | 131 |
| ubic/basecode/dataStructure/matrix/SparseDoubleMatrix.java | 138 |
DoubleMatrix<R, C> returnval = new CompressedSparseDoubleMatrix<R, C>( this.rows(), 1 + endCol - startCol );
int k = 0;
for ( int i = startCol; i <= endCol; i++ ) {
C colName = this.getColName( i );
if ( colName != null ) {
returnval.setColumnName( colName, i );
}
for ( int j = 0, m = this.rows(); j < m; j++ ) {
if ( i == startCol ) {
R rowName = this.getRowName( j );
returnval.setRowName( rowName, j );
}
returnval.set( j, k, this.get( j, i ) );
}
k++;
}
return returnval;
}
/*
* (non-Javadoc)
*
* @see basecode.dataStructure.matrix.DoubleMatrixNamed#getColumn(int)
*/
@Override
public double[] getColumn( int col ) {
double[] result = new double[rows()];
for ( int i = 0; i < rows(); i++ ) {
result[i] = get( i, col );
}
return result;
}
@Override
public Double getObject( int row, int col ) {
return new Double( get( row, col ) );
}
/**
* Return a reference to a specific row.
*
* @param row int
* @return double[]
*/
@Override
public double[] getRow( int row ) { | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/CompressedSparseDoubleMatrix.java | 242 |
| ubic/basecode/dataStructure/matrix/SparseDoubleMatrix.java | 224 |
DoubleMatrix<R, C> returnval = new CompressedSparseDoubleMatrix<R, C>( endRow + 1 - startRow, this.columns() );
int k = 0;
for ( int i = startRow; i <= endRow; i++ ) {
R rowName = this.getRowName( i );
if ( rowName != null ) {
returnval.setRowName( rowName, i );
}
for ( int j = 0, m = this.columns(); j < m; j++ ) {
if ( i == 0 ) {
C colName = this.getColName( j );
returnval.setColumnName( colName, j );
}
returnval.set( k, j, this.get( i, j ) );
}
k++;
}
return returnval;
}
@Override
public boolean isMissing( int i, int j ) {
return Double.isNaN( get( i, j ) );
}
@Override
public int rows() {
return matrix.numRows(); | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/CompressedSparseDoubleMatrix.java | 320 |
| ubic/basecode/dataStructure/matrix/SparseDoubleMatrix.java | 300 |
DoubleMatrix<R, C> returnval = new CompressedSparseDoubleMatrix<R, C>( rowNames.size(), this.columns() );
int currentRow = 0;
for ( R rowName : rowNames ) {
if ( !this.containsRowName( rowName ) ) continue;
int i = this.getRowIndexByName( rowName );
returnval.setRowName( rowName, currentRow );
for ( int j = 0; j < this.columns(); j++ ) {
if ( currentRow == 0 ) {
returnval.setColumnName( this.getColName( j ), j );
}
returnval.set( currentRow, j, this.get( i, j ) );
}
currentRow++;
}
if ( !returnval.getRowNames().containsAll( rowNames ) ) {
throw new IllegalArgumentException( "Invalid rows to select, some are not in the original matrix" );
}
return returnval;
}
@Override
public DoubleMatrix<C, R> transpose() {
throw new UnsupportedOperationException();
}
/**
*
*/
public void trimToSize() { | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/DenseDoubleMatrix.java | 275 |
| ubic/basecode/dataStructure/matrix/FastRowAccessDoubleMatrix.java | 252 |
| ubic/basecode/dataStructure/matrix/SparseDoubleMatrix.java | 266 |
return matrix.size();
}
/*
* (non-Javadoc)
*
* @see ubic.basecode.dataStructure.matrix.DoubleMatrix#subsetColumns(java.util.List)
*/
@Override
public DoubleMatrix<R, C> subsetColumns( List<C> columns ) {
DoubleMatrix<R, C> returnval = new DenseDoubleMatrix<R, C>( this.rows(), columns.size() );
returnval.setRowNames( this.getRowNames() );
for ( int i = 0; i < this.rows(); i++ ) {
int currentColumn = 0;
for ( C c : columns ) {
int j = this.getColIndexByName( c );
returnval.set( i, currentColumn, this.get( i, j ) );
if ( i == 0 ) {
returnval.setColumnName( c, currentColumn );
}
currentColumn++;
}
}
return returnval;
}
@Override
public DoubleMatrix<R, C> subsetRows( List<R> rowNames ) {
DoubleMatrix<R, C> returnval = new DenseDoubleMatrix<R, C>( rowNames.size(), this.columns() ); | |
| File | Line |
|---|---|
| ubic/basecode/math/linearmodels/GenericAnovaResultImpl.java | 155 |
| ubic/basecode/util/r/GenericAnovaResultImpl.java | 160 |
if ( !interactionEffects.containsKey( interactionFactor ) ) {
return Double.NaN;
}
return interactionEffects.get( interactionFactor ).getPValue();
}
@Override
public double getMainEffectDof( String factorName ) {
if ( mainEffects.get( factorName ) == null ) {
return Double.NaN;
}
return mainEffects.get( factorName ).getDof();
}
@Override
public double getMainEffectFStat( String factorName ) {
if ( mainEffects.get( factorName ) == null ) {
return Double.NaN;
}
return mainEffects.get( factorName ).getFStat();
}
/**
* @return names of main effects factors like 'f', 'g'.
*/
@Override
public Collection<String> getMainEffectFactorNames() {
return mainEffects.keySet();
}
@Override
public double getMainEffectPValue( String factorName ) {
if ( mainEffects.get( factorName ) == null ) {
return Double.NaN;
}
return mainEffects.get( factorName ).getPValue();
}
@Override
public boolean hasInteractions() { | |
| File | Line |
|---|---|
| ubic/basecode/math/linearmodels/GenericAnovaResultImpl.java | 216 |
| ubic/basecode/util/r/GenericAnovaResultImpl.java | 208 |
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append( "ANOVA table " ).append( this.getKey() ).append( " \n" );
buf.append( StringUtils.leftPad( "\t", 10 ) ).append( "Df\tSSq\tMSq\tF\tP\n" );
for ( String me : this.getMainEffectFactorNames() ) {
if ( me.equals( LinearModelSummary.INTERCEPT_COEFFICIENT_NAME ) ) {
continue;
}
AnovaEffect a = mainEffects.get( me );
buf.append( a ).append( "\n" );
}
if ( hasInteractions() ) {
for ( TreeSet<String> ifa : interactionEffects.keySet() ) {
AnovaEffect a = this.interactionEffects.get( ifa );
buf.append( a ).append( "\n" );
}
}
buf.append( residual ).append( "\n" );
return buf.toString();
}
} | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/CompressedSparseDoubleMatrix.java | 286 |
| ubic/basecode/dataStructure/matrix/DenseDoubleMatrix.java | 275 |
| ubic/basecode/dataStructure/matrix/FastRowAccessDoubleMatrix.java | 252 |
| ubic/basecode/dataStructure/matrix/SparseDoubleMatrix.java | 266 |
return matrix.numColumns() * matrix.numRows();
}
/*
* (non-Javadoc)
*
* @see ubic.basecode.dataStructure.matrix.DoubleMatrix#subsetColumns(java.util.List)
*/
@Override
public DoubleMatrix<R, C> subsetColumns( List<C> columns ) {
DoubleMatrix<R, C> returnval = new DenseDoubleMatrix<R, C>( this.rows(), columns.size() );
returnval.setRowNames( this.getRowNames() );
for ( int i = 0; i < this.rows(); i++ ) {
int currentColumn = 0;
for ( C c : columns ) {
int j = this.getColIndexByName( c );
returnval.set( i, currentColumn, this.get( i, j ) );
if ( i == 0 ) {
returnval.setColumnName( c, currentColumn );
}
currentColumn++;
}
}
return returnval;
}
@Override
public DoubleMatrix<R, C> subsetRows( List<R> rowNames ) {
DoubleMatrix<R, C> returnval = new CompressedSparseDoubleMatrix<R, C>( rowNames.size(), this.columns() ); | |
| File | Line |
|---|---|
| ubic/basecode/math/linearmodels/LinearModelSummaryImpl.java | 308 |
| ubic/basecode/util/r/LinearModelSummaryImpl.java | 331 |
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
if ( StringUtils.isNotBlank( this.key ) ) {
buf.append( this.key ).append( "\n" );
}
buf.append( "F=" ).append( String.format( "%.2f", this.fStat ) ).append( " Rsquare=" ).append( String.format( "%.2f", this.rSquared ) ).append( "\n" );
buf.append( "Residuals:\n" );
for ( double d : residuals ) {
buf.append( String.format( "%.2f ", d ) );
}
buf.append( "\n\nCoefficients:\n" ).append( contrastCoefficients ).append( "\n" );
if ( this.anovaResult != null ) {
buf.append( this.anovaResult ).append( "\n" );
}
return buf.toString();
}
} | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/CompressedSparseDoubleMatrix.java | 320 |
| ubic/basecode/dataStructure/matrix/FastRowAccessDoubleMatrix.java | 291 |
| ubic/basecode/dataStructure/matrix/SparseDoubleMatrix.java | 300 |
DoubleMatrix<R, C> returnval = new CompressedSparseDoubleMatrix<R, C>( rowNames.size(), this.columns() );
int currentRow = 0;
for ( R rowName : rowNames ) {
if ( !this.containsRowName( rowName ) ) continue;
int i = this.getRowIndexByName( rowName );
returnval.setRowName( rowName, currentRow );
for ( int j = 0; j < this.columns(); j++ ) {
if ( currentRow == 0 ) {
returnval.setColumnName( this.getColName( j ), j );
}
returnval.set( currentRow, j, this.get( i, j ) );
}
currentRow++;
}
if ( !returnval.getRowNames().containsAll( rowNames ) ) {
throw new IllegalArgumentException( "Invalid rows to select, some are not in the original matrix" );
}
return returnval;
}
@Override
public DoubleMatrix<C, R> transpose() { | |
| File | Line |
|---|---|
| ubic/basecode/math/linearmodels/LinearModelSummaryImpl.java | 134 |
| ubic/basecode/util/r/LinearModelSummaryImpl.java | 161 |
}
@Override
public DoubleMatrix<String, String> getContrastCoefficients() {
return contrastCoefficients;
}
@Override
public Map<String, Double> getContrastCoefficients( String factorName ) {
return getContrastAttribute( factorName, "Estimate" );
}
@Override
public Map<String, Double> getContrastCoefficientStderr( String factorName ) {
return getContrastAttribute( factorName, "Std. Error" );
}
@Override
public Map<String, Double> getContrastPValues( String factorName ) {
return getContrastAttribute( factorName, "Pr(>|t|)" );
}
@Override
public Map<String, Double> getContrastTStats( String factorName ) {
return getContrastAttribute( factorName, "t value" );
}
private Map<String, Double> getContrastAttribute( String factorName, String attributeName ) {
Collection<String> terms = term2CoefficientNames.get( factorName );
if ( terms == null ) { | |
| File | Line |
|---|---|
| ubic/basecode/math/metaanalysis/MeanDifferenceMetaAnalysis.java | 98 |
| ubic/basecode/math/metaanalysis/MeanDifferenceMetaAnalysis.java | 124 |
conditionalVariances = cvar.copy();
weights = metaFEWeights( conditionalVariances );
this.q = super.qStatistic( effects, conditionalVariances, super.weightedMean( effects, weights ) );
if ( !fixed ) { // adjust the conditional variances and weights.
this.bsv = metaREVariance( effects, conditionalVariances, weights );
for ( int i = 0; i < conditionalVariances.size(); i++ ) {
conditionalVariances.setQuick( i, conditionalVariances.getQuick( i ) + bsv );
}
weights = metaFEWeights( conditionalVariances );
}
this.e = super.weightedMean( effects, weights );
this.v = super.metaVariance( conditionalVariances );
this.z = Math.abs( e ) / Math.sqrt( v );
this.p = Probability.errorFunctionComplemented( z );
return p;
}
public double run( DoubleArrayList effects, DoubleArrayList controlSizes, DoubleArrayList testSizes ) { | |
| File | Line |
|---|---|
| ubic/basecode/math/linearmodels/LinearModelSummaryImpl.java | 239 |
| ubic/basecode/util/r/LinearModelSummaryImpl.java | 266 |
public String getKey() {
return key;
}
public double getMainEffectPValue( String factorName ) {
if ( anovaResult == null ) return Double.NaN;
return anovaResult.getMainEffectPValue( factorName );
}
@Override
public double getNumeratorDof() {
return this.numeratorDof;
}
@Override
public double getOverallPValue() {
if ( overallPValue == null ) {
if ( Double.isNaN( numeratorDof ) || Double.isNaN( denominatorDof ) || numeratorDof == 0 || denominatorDof == 0 ) {
overallPValue = Double.NaN;
} else {
FDistribution f = new FDistribution( numeratorDof, denominatorDof );
overallPValue = 1.0 - f.cumulativeProbability( this.getFStat() );
}
}
return overallPValue;
}
@Override
public double getPriorDof() { | |
| File | Line |
|---|---|
| ubic/basecode/math/linearmodels/GenericAnovaResultImpl.java | 130 |
| ubic/basecode/util/r/GenericAnovaResultImpl.java | 132 |
Set<String> interactionFactor = new TreeSet<>( Arrays.asList( factorNames ) );
if ( !interactionEffects.containsKey( interactionFactor ) ) {
return Double.NaN;
}
return interactionEffects.get( interactionFactor ).getDof();
}
@Override
public double getInteractionEffectFStat( String... factorNames ) {
if ( interactionEffects.isEmpty() ) {
return Double.NaN;
}
TreeSet<String> interactionFactor = new TreeSet<>( Arrays.asList( factorNames ) );
if ( !interactionEffects.containsKey( interactionFactor ) ) {
return Double.NaN;
}
return interactionEffects.get( interactionFactor ).getFStat();
}
@Override
public double getInteractionEffectPValue( String... factorNames ) { | |
| File | Line |
|---|---|
| ubic/basecode/util/r/AbstractRClient.java | 680 |
| ubic/basecode/util/r/AbstractRClient.java | 896 |
Map<String, OneWayAnovaResult> result = new HashMap<String, OneWayAnovaResult>();
try {
RList mainList = rawResult.asList();
if ( mainList == null ) {
return null;
}
log.debug( mainList.size() + " results." );
for ( int i = 0; i < mainList.size(); i++ ) {
REXP anovaTable = mainList.at( i );
String elementIdentifier = mainList.keyAt( i );
assert elementIdentifier != null;
if ( log.isDebugEnabled() ) log.debug( "Key: " + elementIdentifier );
if ( !anovaTable.isList() || !anovaTable.hasAttribute( "row.names" ) ) {
log.debug( "No anovaresult for " + elementIdentifier );
result.put( elementIdentifier, new OneWayAnovaResultImpl( elementIdentifier ) ); | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/IntegerMatrix.java | 144 |
| ubic/basecode/dataStructure/matrix/StringMatrix.java | 205 |
}
/**
* @return java.lang.Integer
*/
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append( "label" );
for ( int i = 0; i < columns(); i++ ) {
buf.append( "\t" + getColName( i ) );
}
buf.append( "\n" );
for ( int i = 0; i < rows(); i++ ) {
buf.append( getRowName( i ) );
for ( int j = 0; j < columns(); j++ ) {
buf.append( "\t" + get( i, j ) );
}
buf.append( "\n" );
}
return buf.toString();
} | |
| File | Line |
|---|---|
| ubic/basecode/math/StringDistance.java | 136 |
| ubic/basecode/math/StringDistance.java | 166 |
public static double prefixWeightedHammingDistance( String s, String t, double weight ) {
if ( weight <= 0.0 || weight > 1.0 )
throw new IllegalArgumentException( "weight must be between zero and one" );
String trimmedS = s;
String trimmedT = t;
if ( s.length() != t.length() ) {
if ( s.length() > t.length() ) {
trimmedS = s.substring( 0, t.length() );
} else {
trimmedT = t.substring( 0, s.length() );
}
}
double result = 0;
for ( int i = 0; i < trimmedS.length(); i++ ) {
double penalty = Math.max( 0.0, ( 1.0 - i / ( weight * trimmedS.length() ) ) ); | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/ObjectMatrixImpl.java | 180 |
| ubic/basecode/dataStructure/matrix/StringMatrix.java | 198 |
result.set( r, c++, this.get( i, j ) );
}
r++;
}
/*
* FIXME set up the row/column names.
*/
return result;
}
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append( "label" );
for ( int i = 0; i < columns(); i++ ) {
buf.append( "\t" + getColName( i ) );
}
buf.append( "\n" );
for ( int i = 0; i < rows(); i++ ) {
buf.append( getRowName( i ) );
for ( int j = 0; j < columns(); j++ ) { | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/CompressedSparseDoubleMatrix.java | 156 |
| ubic/basecode/dataStructure/matrix/DenseDoubleMatrix.java | 142 |
returnval.setRowName( rowName, j );
}
returnval.set( j, k, this.get( j, i ) );
}
k++;
}
return returnval;
}
/*
* (non-Javadoc)
*
* @see basecode.dataStructure.matrix.DoubleMatrixNamed#getColumn(int)
*/
@Override
public double[] getColumn( int col ) {
double[] result = new double[rows()];
for ( int i = 0; i < rows(); i++ ) {
result[i] = get( i, col );
}
return result;
}
@Override
public Double getObject( int row, int col ) {
return new Double( get( row, col ) );
}
/**
* Return a reference to a specific row.
*
* @param row int
* @return double[]
*/
@Override
public double[] getRow( int row ) { | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/CompressedSparseDoubleMatrix.java | 103 |
| ubic/basecode/dataStructure/matrix/FastRowAccessDoubleMatrix.java | 97 |
| ubic/basecode/dataStructure/matrix/SparseDoubleMatrix.java | 100 |
DoubleMatrix<R, C> returnval = new CompressedSparseDoubleMatrix<R, C>( this.rows(), this.columns() );
for ( int i = 0; i < this.rows(); i++ ) {
returnval.setRowName( this.getRowName( i ), i );
for ( int j = 0; j < this.columns(); j++ ) {
if ( i == 0 ) {
returnval.setColumnName( this.getColName( j ), j );
}
returnval.set( i, j, this.get( i, j ) );
}
}
return returnval;
}
/**
* @param row
* @param column
* @return
*/
@Override
public double get( int row, int column ) { | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/DenseDoubleMatrix.java | 142 |
| ubic/basecode/dataStructure/matrix/FastRowAccessDoubleMatrix.java | 141 |
if ( rowName != null ) returnval.addRowName( rowName );
}
returnval.set( j, k, this.get( j, i ) );
}
k++;
}
return returnval;
}
/*
* (non-Javadoc)
*
* @see basecode.dataStructure.matrix.DoubleMatrixNamed#getColumn(int)
*/
@Override
public double[] getColumn( int col ) {
double[] result = new double[rows()];
for ( int i = 0; i < rows(); i++ ) {
result[i] = get( i, col );
}
return result;
}
/**
* Converts to a String that can be read by read.table in R, using default parameters
*
* @return java.lang.String
*/
/*
* public String toRReadTableString() { Format nf = new Format( "%.4g" ); StringBuffer result = new StringBuffer(
* this.rows() * this.columns() ); if ( this.hasColNames() ) { for ( int i = 0; i < this.columns(); i++ ) {
* result.append( "\"" + this.getColName( i ) +"\" "); System.out.println("\"" + this.getColName( i ) +"\" "); }
* result.append( "\n" ); } for ( int i = 0; i < this.rows(); i++ ) { if ( this.hasRowNames() ) { result.append("\""
* + this.getRowName( i ) + "\"" ); } for ( int j = 0; j < this.columns(); j++ ) { if ( Double.isNaN( this.get( i, j
* ) ) ) { result.append( " NA" ); } else { result.append( " " + nf.format( this.get( i, j ) ) ); } } result.append(
* "\n" ); } return result.toString(); }
*/
@Override
public Double getObject( int row, int col ) {
return new Double( get( row, col ) );
}
/**
* Return a reference to a specific row.
*
* @param row int
* @return double[]
*/
@Override
public double[] getRow( int row ) { | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/CompressedSparseDoubleMatrix.java | 242 |
| ubic/basecode/dataStructure/matrix/FastRowAccessDoubleMatrix.java | 208 |
| ubic/basecode/dataStructure/matrix/SparseDoubleMatrix.java | 224 |
DoubleMatrix<R, C> returnval = new CompressedSparseDoubleMatrix<R, C>( endRow + 1 - startRow, this.columns() );
int k = 0;
for ( int i = startRow; i <= endRow; i++ ) {
R rowName = this.getRowName( i );
if ( rowName != null ) {
returnval.setRowName( rowName, i );
}
for ( int j = 0, m = this.columns(); j < m; j++ ) {
if ( i == 0 ) {
C colName = this.getColName( j );
returnval.setColumnName( colName, j );
} | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/CompressedSparseDoubleMatrix.java | 297 |
| ubic/basecode/dataStructure/matrix/StringMatrix.java | 42 |
DoubleMatrix<R, C> returnval = new DenseDoubleMatrix<R, C>( this.rows(), columns.size() );
returnval.setRowNames( this.getRowNames() );
for ( int i = 0; i < this.rows(); i++ ) {
int currentColumn = 0;
for ( C c : columns ) {
int j = this.getColIndexByName( c );
returnval.set( i, currentColumn, this.get( i, j ) );
if ( i == 0 ) {
returnval.setColumnName( c, currentColumn );
}
currentColumn++;
}
}
return returnval;
} | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/DenseDoubleMatrix.java | 286 |
| ubic/basecode/dataStructure/matrix/StringMatrix.java | 42 |
DoubleMatrix<R, C> returnval = new DenseDoubleMatrix<R, C>( this.rows(), columns.size() );
returnval.setRowNames( this.getRowNames() );
for ( int i = 0; i < this.rows(); i++ ) {
int currentColumn = 0;
for ( C c : columns ) {
int j = this.getColIndexByName( c );
returnval.set( i, currentColumn, this.get( i, j ) );
if ( i == 0 ) {
returnval.setColumnName( c, currentColumn );
}
currentColumn++;
}
}
return returnval;
} | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/FastRowAccessDoubleMatrix.java | 263 |
| ubic/basecode/dataStructure/matrix/StringMatrix.java | 42 |
DoubleMatrix<R, C> returnval = new DenseDoubleMatrix<R, C>( this.rows(), columns.size() );
returnval.setRowNames( this.getRowNames() );
for ( int i = 0; i < this.rows(); i++ ) {
int currentColumn = 0;
for ( C c : columns ) {
int j = this.getColIndexByName( c );
returnval.set( i, currentColumn, this.get( i, j ) );
if ( i == 0 ) {
returnval.setColumnName( c, currentColumn );
}
currentColumn++;
}
}
return returnval;
} | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/SparseDoubleMatrix.java | 277 |
| ubic/basecode/dataStructure/matrix/StringMatrix.java | 42 |
DoubleMatrix<R, C> returnval = new DenseDoubleMatrix<R, C>( this.rows(), columns.size() );
returnval.setRowNames( this.getRowNames() );
for ( int i = 0; i < this.rows(); i++ ) {
int currentColumn = 0;
for ( C c : columns ) {
int j = this.getColIndexByName( c );
returnval.set( i, currentColumn, this.get( i, j ) );
if ( i == 0 ) {
returnval.setColumnName( c, currentColumn );
}
currentColumn++;
}
}
return returnval;
} | |
| File | Line |
|---|---|
| ubic/basecode/math/linearmodels/LeastSquaresFit.java | 1288 |
| ubic/basecode/math/linearmodels/LeastSquaresFit.java | 1558 |
assert this.assign.isEmpty() || this.assign.size() == this.coefficients.rows() : assign.size()
+ " != # coefficients " + this.coefficients.rows();
assert this.coefficients.rows() == A.columns();
// It is somewhat wasteful to hold on to this.
this.fitted = solver.transpose(MatrixUtil.multWithMissing(A, coefficients));
if (this.hasMissing) {
MatrixUtil.maskMissing(b, fitted);
}
this.residuals = b.copy().assign(fitted, Functions.minus);
} | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/CompressedSparseDoubleMatrix.java | 297 |
| ubic/basecode/dataStructure/matrix/ObjectMatrixImpl.java | 48 |
| ubic/basecode/dataStructure/matrix/SparseDoubleMatrix.java | 277 |
DoubleMatrix<R, C> returnval = new DenseDoubleMatrix<R, C>( this.rows(), columns.size() );
returnval.setRowNames( this.getRowNames() );
for ( int i = 0; i < this.rows(); i++ ) {
int currentColumn = 0;
for ( C c : columns ) {
int j = this.getColIndexByName( c );
returnval.set( i, currentColumn, this.get( i, j ) );
if ( i == 0 ) {
returnval.setColumnName( c, currentColumn );
}
currentColumn++;
}
}
return returnval;
}
@Override
public DoubleMatrix<R, C> subsetRows( List<R> rowNames ) { | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/DenseDoubleMatrix.java | 286 |
| ubic/basecode/dataStructure/matrix/ObjectMatrixImpl.java | 48 |
DoubleMatrix<R, C> returnval = new DenseDoubleMatrix<R, C>( this.rows(), columns.size() );
returnval.setRowNames( this.getRowNames() );
for ( int i = 0; i < this.rows(); i++ ) {
int currentColumn = 0;
for ( C c : columns ) {
int j = this.getColIndexByName( c );
returnval.set( i, currentColumn, this.get( i, j ) );
if ( i == 0 ) {
returnval.setColumnName( c, currentColumn );
}
currentColumn++;
}
}
return returnval;
}
@Override
public DoubleMatrix<R, C> subsetRows( List<R> rowNames ) { | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/FastRowAccessDoubleMatrix.java | 263 |
| ubic/basecode/dataStructure/matrix/ObjectMatrixImpl.java | 48 |
DoubleMatrix<R, C> returnval = new DenseDoubleMatrix<R, C>( this.rows(), columns.size() );
returnval.setRowNames( this.getRowNames() );
for ( int i = 0; i < this.rows(); i++ ) {
int currentColumn = 0;
for ( C c : columns ) {
int j = this.getColIndexByName( c );
returnval.set( i, currentColumn, this.get( i, j ) );
if ( i == 0 ) {
returnval.setColumnName( c, currentColumn );
}
currentColumn++;
}
}
return returnval;
}
/*
* (non-Javadoc)
*
* @see ubic.basecode.dataStructure.matrix.DoubleMatrix#subsetRows(java.util.Collection)
*/
@Override
public DoubleMatrix<R, C> subsetRows( List<R> rowNames ) { | |
| File | Line |
|---|---|
| ubic/basecode/math/linearmodels/GenericAnovaResultImpl.java | 63 |
| ubic/basecode/util/r/GenericAnovaResultImpl.java | 72 |
}
@Override
public boolean hasResiduals() {
return residual != null;
}
@Override
public double getResidualsDof() {
return residual != null ? residual.getDof() : Double.NaN;
}
@Override
public double getResidualsFStat() {
return residual != null ? residual.getFStat() : Double.NaN;
}
@Override
public double getResidualsPValue() {
return residual != null ? residual.getPValue() : Double.NaN;
}
@Override
public double getInteractionEffectDof() {
if ( interactionEffects.size() > 1 ) {
throw new IllegalStateException( "Must specify which interaction" ); | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/ObjectMatrixImpl.java | 48 |
| ubic/basecode/dataStructure/matrix/StringMatrix.java | 42 |
ObjectMatrixImpl<R, C, V> returnval = new ObjectMatrixImpl<R, C, V>( this.rows(), columns.size() );
returnval.setRowNames( this.getRowNames() );
for ( int i = 0; i < this.rows(); i++ ) {
int currentColumn = 0;
for ( C c : columns ) {
int j = this.getColIndexByName( c );
returnval.set( i, currentColumn, this.get( i, j ) );
if ( i == 0 ) {
returnval.setColumnName( c, currentColumn );
}
currentColumn++;
}
}
return returnval;
} | |
| File | Line |
|---|---|
| ubic/basecode/dataStructure/matrix/CompressedBitMatrix.java | 290 |
| ubic/basecode/dataStructure/matrix/CompressedBitMatrix.java | 431 |
public void set( int row, int col, int index ) {
if ( index >= this.totalBitsPerItem || row > this.rows || col > this.cols ) {
throw new ArrayIndexOutOfBoundsException( "Attempt to access row=" + row + " col=" + col + " index="
+ index );
}
/*
* We can only fit BITS_PER_ELEMENT values in each matrix cell. If num > 0, we have multiple 'stacked' matrices.
*/
int num = ( int ) Math.floor( ( double ) index / BITS_PER_ELEMENT );
assert num >= 0 && num < matrix.length;
int whichBitToSet = index % BITS_PER_ELEMENT;
long currentValue = Double.doubleToRawLongBits( matrix[num].get( row, col ) ); | |
| File | Line |
|---|---|
| ubic/basecode/datafilter/RowAbsentFilter.java | 136 |
| ubic/basecode/datafilter/RowNameFilter.java | 91 |
rowNames.add( rowName );
kept++;
}
}
M returnval = getOutputMatrix( data, MTemp.size(), numCols );
for ( int i = 0; i < MTemp.size(); i++ ) {
for ( int j = 0; j < numCols; j++ ) {
returnval.set( i, j, MTemp.get( i )[j] );
}
}
returnval.setColumnNames( data.getColNames() );
returnval.setRowNames( rowNames );
log.info( "There are " + kept + " rows left after filtering." );
return returnval;
}
/**
* @param f the matrix containing the flags.
*/
public void setFlagMatrix( StringMatrix<R, C> f ) { | |

