Example usage for org.apache.commons.math3.linear DefaultFieldMatrixPreservingVisitor DefaultFieldMatrixPreservingVisitor

List of usage examples for org.apache.commons.math3.linear DefaultFieldMatrixPreservingVisitor DefaultFieldMatrixPreservingVisitor

Introduction

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

Prototype

public DefaultFieldMatrixPreservingVisitor(final T zero) 

Source Link

Document

Build a new instance.

Usage

From source file:org.briljantframework.array.Matrices.java

/**
 * Convert the field matrix to an array.
 * // ww  w. jav a 2  s  .c  o m
 * @param matrix the matrix
 * @return a new array
 */
public static ComplexArray toArray(FieldMatrix<Complex> matrix) {
    ComplexArray array = Arrays.complexArray(matrix.getRowDimension(), matrix.getColumnDimension());
    matrix.walkInOptimizedOrder(new DefaultFieldMatrixPreservingVisitor<Complex>(Complex.ZERO) {
        @Override
        public void visit(int row, int column, Complex value) {
            array.set(row, column, value);
        }
    });
    return array;
}