• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FieldElement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.commons.math3.FieldElement的典型用法代码示例。如果您正苦于以下问题:Java FieldElement类的具体用法?Java FieldElement怎么用?Java FieldElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FieldElement类属于org.apache.commons.math3包,在下文中一共展示了FieldElement类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getField

import org.apache.commons.math3.FieldElement; //导入依赖的package包/类
/** {@inheritDoc} */
public Field<SparseGradient> getField() {
    return new Field<SparseGradient>() {

        /** {@inheritDoc} */
        public SparseGradient getZero() {
            return createConstant(0);
        }

        /** {@inheritDoc} */
        public SparseGradient getOne() {
            return createConstant(1);
        }

        /** {@inheritDoc} */
        public Class<? extends FieldElement<SparseGradient>> getRuntimeClass() {
            return SparseGradient.class;
        }

    };
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:22,代码来源:SparseGradient.java


示例2: getField

import org.apache.commons.math3.FieldElement; //导入依赖的package包/类
/** {@inheritDoc} */
public Field<DerivativeStructure> getField() {
    return new Field<DerivativeStructure>() {

        /** {@inheritDoc} */
        public DerivativeStructure getZero() {
            return new DerivativeStructure(compiler.getFreeParameters(), compiler.getOrder(), 0.0);
        }

        /** {@inheritDoc} */
        public DerivativeStructure getOne() {
            return new DerivativeStructure(compiler.getFreeParameters(), compiler.getOrder(), 1.0);
        }

        /** {@inheritDoc} */
        public Class<? extends FieldElement<DerivativeStructure>> getRuntimeClass() {
            return DerivativeStructure.class;
        }

    };
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:22,代码来源:DerivativeStructure.java


示例3: outerProduct

import org.apache.commons.math3.FieldElement; //导入依赖的package包/类
/** {@inheritDoc} */
public FieldMatrix<T> outerProduct(FieldVector<T> v) {
    if (v instanceof SparseFieldVector<?>) {
        return outerProduct((SparseFieldVector<T>)v);
    } else {
        final int n = v.getDimension();
        FieldMatrix<T> res = new SparseFieldMatrix<T>(field, virtualSize, n);
        OpenIntToFieldHashMap<T>.Iterator iter = entries.iterator();
        while (iter.hasNext()) {
            iter.advance();
            int row = iter.key();
            FieldElement<T>value = iter.value();
            for (int col = 0; col < n; col++) {
                res.setEntry(row, col, value.multiply(v.getEntry(col)));
            }
        }
        return res;
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:20,代码来源:SparseFieldVector.java


示例4: createRowFieldMatrix

import org.apache.commons.math3.FieldElement; //导入依赖的package包/类
/**
 * Create a row {@link FieldMatrix} using the data from the input
 * array.
 *
 * @param <T> the type of the field elements
 * @param rowData the input row data
 * @return a 1 x rowData.length FieldMatrix
 * @throws NoDataException if {@code rowData} is empty.
 * @throws NullArgumentException if {@code rowData} is {@code null}.
 */
public static <T extends FieldElement<T>> FieldMatrix<T>
    createRowFieldMatrix(final T[] rowData)
    throws NoDataException, NullArgumentException {
    if (rowData == null) {
        throw new NullArgumentException();
    }
    final int nCols = rowData.length;
    if (nCols == 0) {
        throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
    }
    final FieldMatrix<T> m = createFieldMatrix(rowData[0].getField(), 1, nCols);
    for (int i = 0; i < nCols; ++i) {
        m.setEntry(0, i, rowData[i]);
    }
    return m;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:27,代码来源:MatrixUtils.java


示例5: createColumnFieldMatrix

import org.apache.commons.math3.FieldElement; //导入依赖的package包/类
/**
 * Creates a column {@link FieldMatrix} using the data from the input
 * array.
 *
 * @param <T> the type of the field elements
 * @param columnData  the input column data
 * @return a columnData x 1 FieldMatrix
 * @throws NoDataException if {@code data} is empty.
 * @throws NullArgumentException if {@code columnData} is {@code null}.
 */
public static <T extends FieldElement<T>> FieldMatrix<T>
    createColumnFieldMatrix(final T[] columnData)
    throws NoDataException, NullArgumentException {
    if (columnData == null) {
        throw new NullArgumentException();
    }
    final int nRows = columnData.length;
    if (nRows == 0) {
        throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
    }
    final FieldMatrix<T> m = createFieldMatrix(columnData[0].getField(), nRows, 1);
    for (int i = 0; i < nRows; ++i) {
        m.setEntry(i, 0, columnData[i]);
    }
    return m;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:27,代码来源:MatrixUtils.java


示例6: createBlocksLayout

import org.apache.commons.math3.FieldElement; //导入依赖的package包/类
/**
 * Create a data array in blocks layout.
 * <p>
 * This method can be used to create the array argument of the {@link
 * #BlockFieldMatrix(int, int, FieldElement[][], boolean)}
 * constructor.
 * </p>
 * @param <T> Type of the field elements.
 * @param field Field to which the elements belong.
 * @param rows Number of rows in the new matrix.
 * @param columns Number of columns in the new matrix.
 * @return a new data array in blocks layout.
 * @see #toBlocksLayout(FieldElement[][])
 * @see #BlockFieldMatrix(int, int, FieldElement[][], boolean)
 */
public static <T extends FieldElement<T>> T[][] createBlocksLayout(final Field<T> field,
                                                                   final int rows, final int columns) {
    final int blockRows    = (rows    + BLOCK_SIZE - 1) / BLOCK_SIZE;
    final int blockColumns = (columns + BLOCK_SIZE - 1) / BLOCK_SIZE;

    final T[][] blocks = MathArrays.buildArray(field, blockRows * blockColumns, -1);
    int blockIndex = 0;
    for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
        final int pStart  = iBlock * BLOCK_SIZE;
        final int pEnd    = FastMath.min(pStart + BLOCK_SIZE, rows);
        final int iHeight = pEnd - pStart;
        for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
            final int qStart = jBlock * BLOCK_SIZE;
            final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
            final int jWidth = qEnd - qStart;
            blocks[blockIndex] = MathArrays.buildArray(field, iHeight * jWidth);
            ++blockIndex;
        }
    }

    return blocks;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:38,代码来源:BlockFieldMatrix.java


示例7: buildArray

import org.apache.commons.math3.FieldElement; //导入依赖的package包/类
/** Build an array of elements.
 * <p>
 * Complete arrays are filled with field.getZero()
 * </p>
 * @param <T> Type of the field elements
 * @param field field to which array elements belong
 * @param rows number of rows
 * @param columns number of columns (may be negative to build partial
 * arrays in the same way <code>new Field[rows][]</code> works)
 * @return a new array
 */
@SuppressWarnings("unchecked")
protected static <T extends FieldElement<T>> T[][] buildArray(final Field<T> field,
                                                              final int rows,
                                                              final int columns) {
    if (columns < 0) {
        T[] dummyRow = (T[]) Array.newInstance(field.getRuntimeClass(), 0);
        return (T[][]) Array.newInstance(dummyRow.getClass(), rows);
    }
    T[][] array =
        (T[][]) Array.newInstance(field.getRuntimeClass(), new int[] { rows, columns });
    for (int i = 0; i < array.length; ++i) {
        Arrays.fill(array[i], field.getZero());
    }
    return array;
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:27,代码来源:AbstractFieldMatrix.java


示例8: createRowFieldMatrix

import org.apache.commons.math3.FieldElement; //导入依赖的package包/类
/**
 * Create a row {@link FieldMatrix} using the data from the input
 * array.
 *
 * @param <T> the type of the field elements
 * @param rowData the input row data
 * @return a 1 x rowData.length FieldMatrix
 * @throws NoDataException if {@code rowData} is empty.
 * @throws NullArgumentException if {@code rowData} is {@code null}.
 */
public static <T extends FieldElement<T>> FieldMatrix<T>
    createRowFieldMatrix(final T[] rowData) {
    if (rowData == null) {
        throw new NullArgumentException();
    }
    final int nCols = rowData.length;
    if (nCols == 0) {
        throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
    }
    final FieldMatrix<T> m = createFieldMatrix(rowData[0].getField(), 1, nCols);
    for (int i = 0; i < nCols; ++i) {
        m.setEntry(0, i, rowData[i]);
    }
    return m;
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:26,代码来源:MatrixUtils.java


示例9: createColumnFieldMatrix

import org.apache.commons.math3.FieldElement; //导入依赖的package包/类
/**
 * Creates a column {@link FieldMatrix} using the data from the input
 * array.
 *
 * @param <T> the type of the field elements
 * @param columnData  the input column data
 * @return a columnData x 1 FieldMatrix
 * @throws NoDataException if {@code data} is empty.
 * @throws NullArgumentException if {@code columnData} is {@code null}.
 */
public static <T extends FieldElement<T>> FieldMatrix<T>
    createColumnFieldMatrix(final T[] columnData) {
    if (columnData == null) {
        throw new NullArgumentException();
    }
    final int nRows = columnData.length;
    if (nRows == 0) {
        throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
    }
    final FieldMatrix<T> m = createFieldMatrix(columnData[0].getField(), nRows, 1);
    for (int i = 0; i < nRows; ++i) {
        m.setEntry(i, 0, columnData[i]);
    }
    return m;
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:26,代码来源:MatrixUtils.java


示例10: createBlocksLayout

import org.apache.commons.math3.FieldElement; //导入依赖的package包/类
/**
 * Create a data array in blocks layout.
 * <p>
 * This method can be used to create the array argument of the {@link
 * #BlockFieldMatrix(int, int, FieldElement[][], boolean)}
 * constructor.
 * </p>
 * @param <T> Type of the field elements.
 * @param field Field to which the elements belong.
 * @param rows Number of rows in the new matrix.
 * @param columns Number of columns in the new matrix.
 * @return a new data array in blocks layout.
 * @see #toBlocksLayout(FieldElement[][])
 * @see #BlockFieldMatrix(int, int, FieldElement[][], boolean)
 */
public static <T extends FieldElement<T>> T[][] createBlocksLayout(final Field<T> field,
                                                                   final int rows, final int columns) {
    final int blockRows    = (rows    + BLOCK_SIZE - 1) / BLOCK_SIZE;
    final int blockColumns = (columns + BLOCK_SIZE - 1) / BLOCK_SIZE;

    final T[][] blocks = buildArray(field, blockRows * blockColumns, -1);
    int blockIndex = 0;
    for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
        final int pStart  = iBlock * BLOCK_SIZE;
        final int pEnd    = FastMath.min(pStart + BLOCK_SIZE, rows);
        final int iHeight = pEnd - pStart;
        for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
            final int qStart = jBlock * BLOCK_SIZE;
            final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
            final int jWidth = qEnd - qStart;
            blocks[blockIndex] = buildArray(field, iHeight * jWidth);
            ++blockIndex;
        }
    }

    return blocks;
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:38,代码来源:BlockFieldMatrix.java



注:本文中的org.apache.commons.math3.FieldElement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NutMap类代码示例发布时间:2022-05-22
下一篇:
Java FacetResult类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap