package Jama.test;
import Jama.*;
import java.io.*;
import java.util.zip.GZIPInputStream;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
/** TestMatrix tests the functionality of the Jama Matrix class and associated decompositions.
<P>
Run the test from the command line using
<BLOCKQUOTE><PRE><CODE>
java Jama.test.TestMatrix
</CODE></PRE></BLOCKQUOTE>
Detailed output is provided indicating the functionality being tested
and whether the functionality is correctly implemented. Exception handling
is also tested.
<P>
The test is designed to run to completion and give a summary of any implementation errors
encountered. The final output should be:
<BLOCKQUOTE><PRE><CODE>
TestMatrix completed.
Total errors reported: n1
Total warning reported: n2
</CODE></PRE></BLOCKQUOTE>
If the test does not run to completion, this indicates that there is a
substantial problem within the implementation that was not anticipated in the test design.
The stopping point should give an indication of where the problem exists.
**/
public class TestMatrix {
public static void main (String argv[]) {
Matrix A,B,C,Z,O,I,R,S,X,SUB,M,T,SQ,DEF,SOL;
// Uncomment this to test IO in a different locale.
// Locale.setDefault(Locale.GERMAN);
int errorCount=0;
int warningCount=0;
double tmp, s;
double[] columnwise = {1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.};
double[] rowwise = {1.,4.,7.,10.,2.,5.,8.,11.,3.,6.,9.,12.};
double[][] avals = {{1.,4.,7.,10.},{2.,5.,8.,11.},{3.,6.,9.,12.}};
double[][] rankdef = avals;
double[][] tvals = {{1.,2.,3.},{4.,5.,6.},{7.,8.,9.},{10.,11.,12.}};
double[][] subavals = {{5.,8.,11.},{6.,9.,12.}};
double[][] rvals = {{1.,4.,7.},{2.,5.,8.,11.},{3.,6.,9.,12.}};
double[][] pvals = {{1.,1.,1.},{1.,2.,3.},{1.,3.,6.}};
double[][] ivals = {{1.,0.,0.,0.},{0.,1.,0.,0.},{0.,0.,1.,0.}};
double[][] evals =
{{0.,1.,0.,0.},{1.,0.,2.e-7,0.},{0.,-2.e-7,0.,1.},{0.,0.,1.,0.}};
double[][] square = {{166.,188.,210.},{188.,214.,240.},{210.,240.,270.}};
double[][] sqSolution = {{13.},{15.}};
double[][] condmat = {{1.,3.},{7.,9.}};
int rows=3,cols=4;
int invalidld=5;/* should trigger bad shape for construction with val */
int raggedr=0; /* (raggedr,raggedc) should be out of bounds in ragged array */
int raggedc=4;
int validld=3; /* leading dimension of intended test Matrices */
int nonconformld=4; /* leading dimension which is valid, but nonconforming */
int ib=1,ie=2,jb=1,je=3; /* index ranges for sub Matrix */
int[] rowindexset = {1,2};
int[] badrowindexset = {1,3};
int[] columnindexset = {1,2,3};
int[] badcolumnindexset = {1,2,4};
double columnsummax = 33.;
double rowsummax = 30.;
double sumofdiagonals = 15;
double sumofsquares = 650;
/**
Constructors and constructor-like methods:
double[], int
double[][]
int, int
int, int, double
int, int, double[][]
constructWithCopy(double[][])
random(int,int)
identity(int)
**/
print("\nTesting constructors and constructor-like methods...\n");
try{
/** check that exception is thrown in packed constructor with invalid length **/
A = new Matrix(columnwise,invalidld);
errorCount = try_failure(errorCount,"Catch invalid length in packed constructor... ",
"exception not thrown for invalid input");
} catch ( IllegalArgumentException e ) {
try_success("Catch invalid length in packed constructor... ",
e.getMessage());
}
try{
/** check that exception is thrown in default constructor
if input array is 'ragged' **/
A = new Matrix(rvals);
tmp = A.get(raggedr,raggedc);
} catch ( IllegalArgumentException e ) {
try_success("Catch ragged input to default constructor... ",
e.getMessage());
} catch ( java.lang.ArrayIndexOutOfBoundsException e ) {
errorCount = try_failure(errorCount,"Catch ragged input to constructor... ",
"exception not thrown in construction...ArrayIndexOutOfBoundsException thrown later");
}
try{
/** check that exception is thrown in constructWithCopy
if input array is 'ragged' **/
A = Matrix.constructWithCopy(rvals);
tmp = A.get(raggedr,raggedc);
} catch ( IllegalArgumentException e ) {
try_success("Catch ragged input to constructWithCopy... ",e.getMessage());
} catch ( java.lang.ArrayIndexOutOfBoundsException e ) {
errorCount = try_failure(errorCount,"Catch ragged input to constructWithCopy... ","exception not thrown in construction...ArrayIndexOutOfBoundsException thrown later");
}
A = new Matrix(columnwise,validld);
B = new Matrix(avals);
tmp = B.get(0,0);
avals[0][0] = 0.0;
C = B.minus(A);
avals[0][0] = tmp;
B = Matrix.constructWithCopy(avals);
tmp = B.get(0,0);
avals[0][0] = 0.0;
if ( ( tmp - B.get(0,0) ) != 0.0 ) {
/** check that constructWithCopy behaves properly **/
errorCount = try_failure(errorCount,"constructWithCopy... ","copy not effected... data visible outside");
} else {
try_success("constructWithCopy... ","");
}
avals[0][0] = columnwise[0];
I = new Matrix(ivals);
try {
check(I,Matrix.identity(3,4));
try_success("identity... ","");
} catch ( java.lang.RuntimeException e ) {
errorCount = try_failure(errorCount,"identity... ","identity Matrix not successfully created");
}
/**
Access Methods:
getColumnDimension()
getRowDimension()
getArray()
getArrayCopy()
getColumnPackedCopy()
getRowPackedCopy()
get(int,int)
getMatrix(int,int,int,int)
getMatrix(int,int,int[])
getMatrix(int[],int,int)
getMatrix(int[],int[])
set(int,int,double)
setMatrix(int,int,int,int,Matrix)
setMatrix(int,int,int[],Matrix)
setMatrix(int[],int,int,Matrix)
setMatrix(int[],int[],Matrix)
**/
print("\nTesting access methods...\n");
/**
Various get methods:
**/
B = new Matrix(avals);
if (B.getRowDimension() != rows) {
errorCount = try_failure(errorCount,"getRowDimension... ","");
} else {
try_success("getRowDimension... ","");
}
if (B.getColumnDimension() != cols) {
errorCount = try_failure(errorCount,"getColumnDimension... ","");
} else {
try_success("getColumnDimension... ","");
}
B = new Matrix(avals);
double[][] barray = B.getArray();
if ( barray != avals ) {
errorCount = try_failure(errorCount,"getArray... ","");
} else {
try_success("getArray... ","");
}
barray = B.getArrayCopy();
if ( barray == avals ) {
errorCount = try_failure(errorCount,"getArrayCopy... ","data not (deep) copied");
}
try {
check(barray,avals);
try_success("getArrayCopy... ","");
} catch ( java.lang.RuntimeException e ) {
errorCount = try_failure(errorCount,"getArrayCopy... ","data not successfully (deep) copied");
}
double[] bpacked = B.getColumnPackedCopy();
try {
check(bpacked,columnwise);
try_success("getColumnPackedCopy... ","");
} catch ( java.lang.RuntimeException e ) {
errorCount = try_failure(errorCount,"getColumnPackedCopy... ","data not successfully (deep) copied by columns");
}
bpacked = B.getRowPackedCopy();
try {
check(bpacked,rowwise);
try_success("getRowPackedCopy... ","");
} catch ( java.lang.RuntimeExc
没有合适的资源?快使用搜索试试~ 我知道了~
jahp.2.1.zip_JAHP_ahp_ahp java_jahp.2.1
共127个文件
class:42个
html:31个
java:31个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 185 浏览量
2022-09-20
15:34:51
上传
评论
收藏 322KB ZIP 举报
温馨提示
erp decision with ahp
资源推荐
资源详情
资源评论
收起资源包目录
jahp.2.1.zip_JAHP_ahp_ahp java_jahp.2.1 (127个子文件)
appartement.ahp 8KB
autoroute.ahp 4KB
implementMAS.ahp2 4KB
do.bat 3KB
ChangeLog 464B
CHANGES 504B
TestMatrix.class 19KB
Matrix.class 11KB
EigenvalueDecomposition.class 10KB
JAHP.class 7KB
Criterium.class 7KB
SingularValueDecomposition.class 6KB
Hierarchy.class 5KB
PairwiseComparisonMatrix.class 5KB
ComparisonPane.class 4KB
CriteriumShowPanel.class 4KB
MagicSquareExample.class 3KB
AlternativesModel.class 3KB
AlternativePanel.class 3KB
HierarchyModel.class 3KB
HierarchyTree.class 3KB
LUDecomposition.class 3KB
OwnTest.class 3KB
QRDecomposition.class 3KB
AlternativesTable.class 2KB
Rightpanel.class 2KB
Alternative.class 2KB
CriteriumModifyPanel.class 2KB
AlternativesPanel.class 2KB
CriteriumPanel.class 2KB
CriteriaPanel.class 2KB
CriteriumSonTablePane.class 2KB
CholeskyDecomposition.class 2KB
CriteriumSonTablePane$CriteriumTableModel.class 2KB
Leftpanel.class 1KB
About.class 1KB
Activity.class 918B
ImagePanel.class 850B
About$1.class 477B
JAHP$1.class 456B
Maths.class 442B
CriteriumSonTablePane$1.class 407B
CriteriumModifyPanel$1.class 405B
CriteriumShowPanel$1.class 401B
AlternativesPanel$1.class 399B
AlternativePanel$1.class 397B
CriteriumPanel$1.class 393B
ComparisonPane$1.class 393B
COPYING 18KB
stylesheet.css 1KB
stylesheet.css 1KB
money.gif 1KB
Edit24.gif 1KB
ComposeMail24.gif 412B
inherit.gif 57B
Matrix.html 55KB
index-all.html 26KB
LUDecomposition.html 12KB
SingularValueDecomposition.html 12KB
QRDecomposition.html 11KB
EigenvalueDecomposition.html 11KB
serialized-form.html 11KB
CholeskyDecomposition.html 10KB
MagicSquareExample.html 10KB
TestMatrix.html 8KB
Maths.html 7KB
help-doc.html 7KB
package-summary.html 5KB
overview-tree.html 5KB
package-tree.html 5KB
package-summary.html 4KB
package-summary.html 4KB
overview-summary.html 4KB
package-tree.html 4KB
package-tree.html 4KB
package-summary.html 4KB
package-tree.html 4KB
deprecated-list.html 4KB
allclasses-frame.html 1KB
overview-frame.html 1KB
package-frame.html 1KB
index.html 760B
package-frame.html 754B
package-frame.html 726B
package-frame.html 716B
packages.html 645B
INSTALLATION 1KB
TestMatrix.java 41KB
Matrix.java 28KB
EigenvalueDecomposition.java 27KB
SingularValueDecomposition.java 15KB
Criterium.java 13KB
JAHP.java 9KB
PairwiseComparisonMatrix.java 9KB
Hierarchy.java 8KB
LUDecomposition.java 8KB
OwnTest.java 7KB
AlternativesModel.java 6KB
QRDecomposition.java 6KB
CriteriumShowPanel.java 6KB
共 127 条
- 1
- 2
资源评论
Kinonoyomeo
- 粉丝: 77
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功