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

📄 c_matrix.java

📁 逆矩阵运算模型。关于数据预测的。根据既有数据预测下一期数据
💻 JAVA
字号:
package com.strongit.bi.mbs.model;



/**
 * 
 */


/**
 * <p>逆矩阵运算模型</p>
 * <p>Description:逆矩阵运算模型的算法</p>
 * 
 *
 */
public class C_Matrix {
	public double[][]  getMatrix(double Vpcmatrix[][]){

	    int i,j;
	    i = j = Vpcmatrix[0].length;
	double[][]  getathwart =new double[i][j];
	double[][] Vp = new double [i+1][3*j];
//	int i,j;
	for(int k=1;k<i+1;k++)
	{
	for(int t=1;t<3*j;t++)
	{
	Vp[k][t] = 0.0;
	}
	}
	    for (int k=1;k<=i;k++)
	     for (int m=1;m<=j;m++){
	       Vp[k][m] = Vpcmatrix[k-1][m-1];
	     }
//	input the data of the matrix
	   /*
	Vp[1][1] = 1;
	Vp[1][2] = 2;
	Vp[1][3] = 3;
	Vp[2][1] = 2;
	Vp[2][2] = 2;
	Vp[2][3] = 1;
	Vp[3][1] = 3;
	Vp[3][2] = 4;
	Vp[3][3] = 3;
	*/

	for(int x=1;x<=i;x++)
	{
	for(int y=1;y<=j;y++)
	{
	}
	}
//	add the identity array at the end
	for(int k=1;k<=i;k++)
	{
	for(int t=j+1;t<=j*2;t++)
	{
	 if((t-k)==j)
	 {
	  Vp[k][t]=1.0;
	 }
	 else
	 {
	  Vp[k][t]=0;
	 }
	}
	}
//	get the change of the array
	for(int k=1;k<=i;k++)
	{
	if(Vp[k][k]!=1)
	{
	 double bs = Vp[k][k];
	 Vp[k][k]=1;
	 for(int p=k+1;p<=j*2;p++)
	 {
	   if(bs!=0)
	     Vp[k][p]/=bs;
	 }
	}

	for(int q=1;q<=i;q++)
	{
	 if(q!=k)
	 {
	  double bs = Vp[q][k];	  
	  for(int p=1;p<=j*2;p++)
	  {
	   Vp[q][p]-=bs*Vp[k][p];
	  }
	 }
	 else
	 {
	  continue;
	 }
	}
	}
//	print out the result of the change
	for(int x=1;x<=i;x++)
	{
	for(int y=j+1;y<=j*2;y++)
	{
	 getathwart[x-1][y-j-1]=Vp[x][y];
	}
	}
	 return  getathwart;

	}

}

⌨️ 快捷键说明

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