com.clust4j.utils.MatrixFormatter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clust4j Show documentation
Show all versions of clust4j Show documentation
A suite of classification clustering algorithm implementations for Java. A number of partitional, hierarchical and density-based algorithms including DBSCAN, k-Means, k-Medoids, MeanShift, Affinity Propagation, HDBSCAN and more.
The newest version!
/*******************************************************************************
* Copyright 2015, 2016 Taylor G Smith
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.clust4j.utils;
import java.text.NumberFormat;
import java.util.ArrayList;
import org.apache.commons.math3.linear.RealMatrix;
public class MatrixFormatter extends TableFormatter {
private static final long serialVersionUID = 6065772725783899020L;
public MatrixFormatter() {
this(DEFAULT_NUMBER_FORMAT);
}
public MatrixFormatter(final ColumnAlignment align) {
super(align);
}
public MatrixFormatter(final NumberFormat format) {
this(DEFAULT_PREFIX, DEFAULT_SUFFIX, DEFAULT_ROW_PREFIX, DEFAULT_ROW_SUFFIX,
DEFAULT_ROW_SEPARATOR, DEFAULT_COLUMN_SEPARATOR, DEFAULT_WHITE_SPACE, format);
}
public MatrixFormatter(final String pref, final String suff,
final String rowPref, final String rowSuff,
final String rowSep, final String colSep,
final int whiteSpace, final NumberFormat format) {
super(pref, suff, rowPref, rowSuff, rowSep, colSep, whiteSpace, format);
}
public Table format(double[][] mat) {
return format(mat, mat.length);
}
public Table format(double[][] mat, int numRows) {
final ArrayList