⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matrixvectorreader.java

📁 另一个功能更强大的矩阵运算软件开源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            data[i] = getDouble();    }    /**     * Reads the array data     */    public void readArray(float[] data) throws IOException {        int size = data.length;        for (int i = 0; i < size; ++i)            data[i] = getFloat();    }    /**     * Reads the array data     */    public void readArray(int[] data) throws IOException {        int size = data.length;        for (int i = 0; i < size; ++i)            data[i] = getInt();    }    /**     * Reads the array data     */    public void readArray(long[] data) throws IOException {        int size = data.length;        for (int i = 0; i < size; ++i)            data[i] = getLong();    }    /**     * Reads the array data. The first array will contain real entries, while     * the second contain imaginary entries     */    public void readArray(double[] dataR, double[] dataI) throws IOException {        int size = dataR.length;        if (size != dataI.length)            throw new IllegalArgumentException(                    "All arrays must be of the same size");        for (int i = 0; i < size; ++i) {            dataR[i] = getDouble();            dataI[i] = getDouble();        }    }    /**     * Reads the array data. The first array will contain real entries, while     * the second contain imaginary entries     */    public void readArray(float[] dataR, float[] dataI) throws IOException {        int size = dataR.length;        if (size != dataI.length)            throw new IllegalArgumentException(                    "All arrays must be of the same size");        for (int i = 0; i < size; ++i) {            dataR[i] = getFloat();            dataI[i] = getFloat();        }    }    /**     * Reads a coordinate vector     */    public void readCoordinate(int[] index, double[] data) throws IOException {        int size = index.length;        if (size != data.length)            throw new IllegalArgumentException(                    "All arrays must be of the same size");        for (int i = 0; i < size; ++i) {            index[i] = getInt();            data[i] = getDouble();        }    }    /**     * Reads a coordinate vector     */    public void readCoordinate(int[] index, float[] data) throws IOException {        int size = index.length;        if (size != data.length)            throw new IllegalArgumentException(                    "All arrays must be of the same size");        for (int i = 0; i < size; ++i) {            index[i] = getInt();            data[i] = getFloat();        }    }    /**     * Reads a coordinate vector     */    public void readCoordinate(int[] index, int[] data) throws IOException {        int size = index.length;        if (size != data.length)            throw new IllegalArgumentException(                    "All arrays must be of the same size");        for (int i = 0; i < size; ++i) {            index[i] = getInt();            data[i] = getInt();        }    }    /**     * Reads a coordinate vector     */    public void readCoordinate(int[] index, long[] data) throws IOException {        int size = index.length;        if (size != data.length)            throw new IllegalArgumentException(                    "All arrays must be of the same size");        for (int i = 0; i < size; ++i) {            index[i] = getInt();            data[i] = getLong();        }    }    /**     * Reads a coordinate vector. First data array contains real entries, and     * the second contains imaginary entries     */    public void readCoordinate(int[] index, float[] dataR, float[] dataI)            throws IOException {        int size = index.length;        if (size != dataR.length || size != dataI.length)            throw new IllegalArgumentException(                    "All arrays must be of the same size");        for (int i = 0; i < size; ++i) {            index[i] = getInt();            dataR[i] = getFloat();            dataI[i] = getFloat();        }    }    /**     * Reads a coordinate vector. First data array contains real entries, and     * the second contains imaginary entries     */    public void readCoordinate(int[] index, double[] dataR, double[] dataI)            throws IOException {        int size = index.length;        if (size != dataR.length || size != dataI.length)            throw new IllegalArgumentException(                    "All arrays must be of the same size");        for (int i = 0; i < size; ++i) {            index[i] = getInt();            dataR[i] = getDouble();            dataI[i] = getDouble();        }    }    /**     * Reads a pattern vector     */    public void readPattern(int[] index) throws IOException {        int size = index.length;        for (int i = 0; i < size; ++i)            index[i] = getInt();    }    /**     * Reads a coordinate matrix     */    public void readCoordinate(int[] row, int[] column, double[] data)            throws IOException {        int size = row.length;        if (size != column.length || size != data.length)            throw new IllegalArgumentException(                    "All arrays must be of the same size");        for (int i = 0; i < size; ++i) {            row[i] = getInt();            column[i] = getInt();            data[i] = getDouble();        }    }    /**     * Reads a coordinate matrix     */    public void readCoordinate(int[] row, int[] column, float[] data)            throws IOException {        int size = row.length;        if (size != column.length || size != data.length)            throw new IllegalArgumentException(                    "All arrays must be of the same size");        for (int i = 0; i < size; ++i) {            row[i] = getInt();            column[i] = getInt();            data[i] = getFloat();        }    }    /**     * Reads a coordinate matrix     */    public void readCoordinate(int[] row, int[] column, int[] data)            throws IOException {        int size = row.length;        if (size != column.length || size != data.length)            throw new IllegalArgumentException(                    "All arrays must be of the same size");        for (int i = 0; i < size; ++i) {            row[i] = getInt();            column[i] = getInt();            data[i] = getInt();        }    }    /**     * Reads a coordinate matrix     */    public void readCoordinate(int[] row, int[] column, long[] data)            throws IOException {        int size = row.length;        if (size != column.length || size != data.length)            throw new IllegalArgumentException(                    "All arrays must be of the same size");        for (int i = 0; i < size; ++i) {            row[i] = getInt();            column[i] = getInt();            data[i] = getLong();        }    }    /**     * Reads a pattern matrix     */    public void readPattern(int[] row, int[] column) throws IOException {        int size = row.length;        if (size != column.length)            throw new IllegalArgumentException(                    "All arrays must be of the same size");        for (int i = 0; i < size; ++i) {            row[i] = getInt();            column[i] = getInt();        }    }    /**     * Reads a coordinate matrix. First data array contains real entries, and     * the second contains imaginary entries     */    public void readCoordinate(int[] row, int[] column, double[] dataR,            double[] dataI) throws IOException {        int size = row.length;        if (size != column.length || size != dataR.length                || size != dataI.length)            throw new IllegalArgumentException(                    "All arrays must be of the same size");        for (int i = 0; i < size; ++i) {            row[i] = getInt();            column[i] = getInt();            dataR[i] = getDouble();            dataI[i] = getDouble();        }    }    /**     * Reads a coordinate matrix. First data array contains real entries, and     * the second contains imaginary entries     */    public void readCoordinate(int[] row, int[] column, float[] dataR,            float[] dataI) throws IOException {        int size = row.length;        if (size != column.length || size != dataR.length                || size != dataI.length)            throw new IllegalArgumentException(                    "All arrays must be of the same size");        for (int i = 0; i < size; ++i) {            row[i] = getInt();            column[i] = getInt();            dataR[i] = getFloat();            dataI[i] = getFloat();        }    }    /**     * Reads an integer     */    private int getInt() throws IOException {        st.nextToken();        if (st.ttype == StreamTokenizer.TT_WORD)            return Integer.parseInt(st.sval);        else if (st.ttype == StreamTokenizer.TT_EOF)            throw new EOFException("End-of-File encountered during parsing");        else            throw new IOException("Unknown token found during parsing");    }    /**     * Reads a long     */    private long getLong() throws IOException {        st.nextToken();        if (st.ttype == StreamTokenizer.TT_WORD)            return Long.parseLong(st.sval);        else if (st.ttype == StreamTokenizer.TT_EOF)            throw new EOFException("End-of-File encountered during parsing");        else            throw new IOException("Unknown token found during parsing");    }    /**     * Reads a double     */    private double getDouble() throws IOException {        st.nextToken();        if (st.ttype == StreamTokenizer.TT_WORD)            return Double.parseDouble(st.sval);        else if (st.ttype == StreamTokenizer.TT_EOF)            throw new EOFException("End-of-File encountered during parsing");        else            throw new IOException("Unknown token found during parsing");    }    /**     * Reads a float     */    private float getFloat() throws IOException {        st.nextToken();        if (st.ttype == StreamTokenizer.TT_WORD)            return Float.parseFloat(st.sval);        else if (st.ttype == StreamTokenizer.TT_EOF)            throw new EOFException("End-of-File encountered during parsing");        else            throw new IOException("Unknown token found during parsing");    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -