帮助排行榜

口袋妖怪网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 6462|回复: 68

【土豪属性】人生的第一笔工资啊工资

[复制链接]

92

主题

9038

帖子

9382

积分

版主

Youth

威望
15
帅气
26
聪明
24
强壮
1
美丽
158
可爱
21
星沙
0
金钱
149930
发表于 2010-6-27 11:13:30 | 显示全部楼层 |阅读模式
= =混了3个月实验室,混了3个月TA
终于从教授手里接过了12000MOP
(泪目ing)终于见回头钱了啊!有钱买机票回家了啊!
可以把妹了啊(雾)
(怨念)啊喂,给100面值的会死啊!500的摸着没厚实感啊……
以上...最近土豪属性严重,另..无图无真相……
===========
附带问题:

#include<iostream>

#include<string>

#include<algorithm>

#include<iomanip>

#include<cmath>

#include<vector>

using namespace std;//注意数组的初始化

void Multiply(vector<vector<vector<double>>> MatrixA, int mA, int nA, vector<vector<vector<double>>>MatrixB,int mB, int nB,vector<vector<vector<double>>>MatrixC,int mC,int nC,int k);

void Add(vector<vector<vector<double>>> MatrixA, int mA, int nA, vector<vector<vector<double>>>MatrixB,int mB, int nB,vector<vector<vector<double>>>MatrixC,int mC,int nC);

void LUDcomposition(vector<vector<double>>matrixA,vector<vector<double>> matrixL,vector<vector<double>> matrixU,int size);

int main(){

//----------------------number of points------------------------------------

int X,Y=1,numberofpoints;

std::cout<<"please input the total number of points you have in this structure: ";

std::cin >> numberofpoints;

X=numberofpoints;

vector<vector<double> >coordinate;

coordinate.resize(numberofpoints);

for(int i=0;i<numberofpoints;i++)

coordinate.resize(2);

for(int i=0,j=1;i<numberofpoints;i++,j++){

std::cout<<"please input the coordinates of point"<< j <<" in this structure: " ;

std::cin>>coordinate[0];

/*std::cout<<"please input the Y coordinates of point"<< j <<" in this structure: " ;*/

std::cin>>coordinate[1];

}

//-----------------------number of members----------------------------------

int numberofmembers,N1,N2=4;

double bandwidth=0;

cout<<" please input the total number of members you have in this structure: ";

cin>>numberofmembers;

N1=numberofmembers;

vector<vector<double>>member;

member.resize(numberofmembers);

for(int i=0;i<numberofmembers;i++)

member.resize(5);

vector<vector<double>>length;

length.resize(numberofmembers);

for(int i=0;i<numberofmembers;i++)

length.resize(1);

for(int i=0,j=0;i<numberofmembers;i++){

j++;

cout<< "please input the serial number of the start point of member "<< j <<" in this structure: " ;

cin>> member[j-1][0];

cout<< "please input the serial number of the end point of member "<< j <<" in this structure: " ;

cin>> member[j-1][1];

cout<< "please input the E Value of member "<< j <<" in this structure: " ;

cin>> member[j-1][2];

cout<< "please input the I value of member "<< j <<" in this structure: " ;

cin>> member[j-1][3];

cout<< "please input the A value of member "<< j <<" in this structure: " ;

cin>> member[j-1][4];

if(member[j-1][1]-member[j-1][0]+1>bandwidth)

bandwidth=member[j-1][1]-member[j-1][0]+1;

}

//==============================================================================================================

//-------------------------------------------boundary condition---------------------

int numberofBC=0;

vector<vector<double>>BC;//boundary condition

BC.resize(3*numberofpoints);

for(int i=0;i<3*numberofpoints;i++){

BC.resize(1);

BC[0]=1;}

vector<vector<double>> moveandrotate;//move or rotate

moveandrotate.resize(numberofpoints);

for(int i=0;i<numberofpoints;i++)

moveandrotate.resize(2);

vector<vector<double>> boundarycase;//boundarycase

boundarycase.resize(numberofpoints);

for(int i=0;i<numberofpoints;i++)

boundarycase.resize(2);

vector<vector<double>> pointMatrix;

pointMatrix.resize(3*numberofpoints);

for(int i=0;i<3*numberofpoints;i++)

pointMatrix.resize(1);

vector<vector<double>> conditionmatrix;//one of the final three matrix

conditionmatrix.resize(numberofpoints*3);

for(int i=0;i<numberofpoints*3;i++)

conditionmatrix.resize(1);

char settlementorrotate;

for(int i=0,j=0;i< numberofpoints;i++){

int P=0;

cout<<" input the serial number of the point which have boundary conditions :( input 0 or press the enter if there is no more) " ;

cin>> P;

if (P==0){

break;

}

j++;

cout<< "does it CAN move in X direction of point " << P <<" in this condition type:(press 1 for move; press 0 for not move) " ;

cin>> BC[3*(P-1)][0];

if(BC[3*(P-1)][0]==0)

numberofBC+=1;

cout<< "does it CAN move in Y direction of point " << P <<" in this condition type:(press 1 for move; press 0 for not move) " ;

cin>> BC[3*P-2][0];

if(BC[3*P-2][0]==0)

numberofBC+=1;

cout<< "does it rotate of the point " << P <<" in this condition type: (press 1 for rotate; press 0 for not rotate)" ;

cin>> BC[3*P-1][0];

if(BC[3*P-1][0]==0)

numberofBC+=1;

}

for(int i=0,j=0;i< numberofpoints;i++){

int P=0;

cout<<" input the serial number of the point which have extra settlement/rotate:( input 0 or press the enter if there is no more) " ;

cin>> P;

if (P==0){

break;

}

/*cout<<"it is a settlement or rotate?(S: settlement R: rotate:) " ;*/

settlementorrotate = 'S';

switch(settlementorrotate){

case 'S':{

moveandrotate[P-1][0]=1;

cout<<"the distance it can move in X direction (right direction is positive): ";

cin>>pointMatrix[3*(P-1)][0];

conditionmatrix[3*(P-1)][0]+=-pointMatrix[3*(P-1)][0];

cout<<"the distance it can move in Y direction:(up direction is positive) ";

cin>>pointMatrix[3*P-2][0];

conditionmatrix[3*(P-1)][0]+=-pointMatrix[3*(P-1)][0];

continue;

}

/*case 'R':{

moveandrotate[P-1][1]=1;

cout<<"the degree it rotate in (counter-clockwise): ";

cin>>pointMatrix[3*P-1][0];

conditionmatrix[3*(P-1)][0]+=pointMatrix[3*(P-1)][0]*3.14159/180;

continue;

}*/

default: continue;

}

}

//---------------------------UDL-------------------------------------

vector<vector<double> >UDL;int M;

UDL.resize(numberofmembers);

for(int i=0;i<numberofmembers;i++)

UDL.resize(5);

vector<vector<double> >externalforcematrix;

externalforcematrix.resize(numberofpoints*3);

for(int i=0;i<numberofpoints*3;i++)

externalforcematrix.resize(1);

for(int i=0,j=0;i<numberofmembers;i++){

M=0;

cout<<" input the serial number of the member which has the uniform disturbute load(UDL):( input 0 or press enter if there is no more) " ;

cin>> M;

if (M==0){

break;

}

j++;

cout<<"which direction of the UDL on the member "<< M<<"on this structure ( 0 for X(right) direction; 1 for Y(up) direction; press anyother number for other direction) ";

cin>> UDL[M-1][4];

cout<< "please input the distance between the point " << member[M-1][0]<<" and the start point of the uniform distribute load on the member "<< M <<" in this structure: " ;

cin>> UDL[M-1][0];

cout<< "please input the start value of the uniform disturbute load on the member "<< M <<" on this structure:(direction vertical up is positive) " ;

cin>> UDL[M-1][1];

UDL[M-1][3] = UDL[M-1][1];

cout<< "please input the distance between the point " << member[M-1][0]<<" and the end point of the uniform distribute load on the member "<< M <<" in this structure: " ;

cin>> UDL[M-1][2];

/*cout<< "please input the end value of the uniform disturbute load on the member "<< M <<" on this structure:(Y direction vertical up is positive,X directin right is positive) " ;

cin>> UDL[M-1][3];*/

/*if(UDL[M-1][1]!=UDL[M-1][3]){

cout<< "this program does not fit for this load ";continue;}*/

//-----------------------------------external force MATRIX for UDL-------------------------------------------------------------------------

int k=(int)member[M-1][1];

int l=(int)member[M-1][0];

double m=coordinate[k-1][1]-coordinate[l-1][1];

double n=coordinate[k-1][0]-coordinate[l-1][0];

double transnumber=sqrt(pow(m,2)+pow(n,2));

length[0]=transnumber;

int initialpoint=(int)member[M-1][0]-1;

int finalpoint=(int)member[M-1][1]-1;

if(UDL[M-1][1]==UDL[M-1][3] && UDL[M-1][0]==0 && UDL[M-1][2]==transnumber){

if(UDL[M-1][4]==1){

externalforcematrix[finalpoint*3][0]+=0;

externalforcematrix[finalpoint*3+1][0]+=-UDL[M-1][1]*transnumber/2;

externalforcematrix[finalpoint*3+2][0]+=(UDL[M-1][1]*pow(transnumber,2))/12;

externalforcematrix[initialpoint*3][0]+=0;

externalforcematrix[initialpoint*3+1][0]+=-UDL[M-1][1]*transnumber/2;

externalforcematrix[initialpoint*3+2][0]+=-(UDL[M-1][1]*pow(transnumber,2))/12;

}

else if(UDL[M-1][4]==0){

externalforcematrix[initialpoint*3][0]+=-UDL[M-1][1]*transnumber/2;

externalforcematrix[initialpoint*3+1][0]+=0;

externalforcematrix[initialpoint*3+2][0]+=-(UDL[M-1][1]*pow(transnumber,2))/12;

externalforcematrix[finalpoint*3][0]+=-UDL[M-1][1]*transnumber/2;

externalforcematrix[finalpoint*3+1][0]+=0;

externalforcematrix[finalpoint*3+2][0]+=(UDL[M-1][1]*pow(transnumber,2))/12;

}

}

else cout<< "error! ";

continue;

}

//-----------------------------point moment------------------------------

vector<vector<double> >PM;

PM.resize(numberofmembers);

for(int i=0;i<numberofmembers;i++)

PM.resize(2);

//for(int i=0,j=0;i<numberofmembers;i++){

// M=0;

// /*cout<<" input the serial number of the member which has the extra moment:( input 0 or press enter if there is no more) " ;

// cin>> M;*/

// if (M==0){

// break;

// }

// j++;

// cout<< "please input the distance between the point " << member[M-1][0]<<" and the point of extra moment on the member "<< M <<" in this structure: " ;

// cin>> PM[M-1][0];

// cout<< "please input the value of the extra moment on the member "<< M <<" " ;

// cin>> PM[M-1][1];

// if(PM[M-1][0]==0 )

// externalforcematrix[3*(int)member[M-1][0]-1][0]+=PM[M-1][1];

// else if(PM[M-1][0]==length[M-1][0])

// externalforcematrix[3*(int)member[M-1][1]-1][0]+=PM[M-1][1];

// else if (PM[M-1][0]>length[M-1][0])

// cout<<"your input have some errors please input it again: "<<endl; continue;

//

// externalforcematrix[3*(int)member[M-1][0]-1][0]+=PM[M-1][1]*(length[M-1][0]-PM[M-1][0])*(2*PM[M-1][0]-(length[M-1][0]-PM[M-1][0]))/pow(length[M-1][0],2);

// externalforcematrix[3*(int)member[M-1][1]-1][0]+=PM[M-1][1]*PM[M-1][0]*(2*(length[M-1][0]-PM[M-1][0])-PM[M-1][0])/pow(length[M-1][0],2);

//}

//---------------------------CS------------------------------------------

vector<double> C(numberofmembers,0);

vector<double> S(numberofmembers,0);

for(int i=0,j=1,k=0,l=0;i<numberofmembers;i++,j++){

double m=0,n=0;

k=(int)member[j-1][1];

l=(int)member[j-1][0];

m=coordinate[k-1][1]-coordinate[l-1][1];

n=coordinate[k-1][0]-coordinate[l-1][0];

length[0]=sqrt(pow(m,2)+pow(n,2));

S=m/length[0];

C=n/length[0];}

/*cout<<"C value is "<<endl;

for(int j=0;j<numberofmembers;j++)

cout<<C[j]<<" ";

cout<<"S value is "<<endl;

for(int k=0;k<numberofmembers;k++)

cout<<S[k]<<" ";*/

//----------------------CL---------------------------------------------------

vector<vector<double> >CL;

CL.resize(numberofmembers);

for(int i=0;i<numberofmembers;i++)

CL.resize(5);

for(int i=0;i<numberofmembers;i++){

M=0;

cout<<" input the serial number of the member which has constant force(CL):( input 0 if there is no more) ";

cin>> M;

if (M==0){

break;

}

cout<< "please input the member distance between the point " << member[M-1][0]<<" and the start point of the constant load on the member "<< M <<" in this structure: " ;

cin>> CL[M-1][0];

cout<< "please input the value of the point Load on the member "<< M <<" in this structure:(direction vertical up and horizontal right is positive) " ;

cin>> CL[M-1][1];

cout<< "please input the angle of this point Load due to the member(counter-clock wise) "<< M <<" in this structure: " ;

cin>> CL[M-1][2];

//-----------------------------------external force MATRIX for CL-------------------------------------------------------------------------

double angles;

if (CL[M-1][1]<0)

angles=CL[M-1][2]-180;

else angles=CL[M-1][2];

if(angles!=90){

if(BC[3*(int)(member[M-1][0]-1)][0]=1){

externalforcematrix[3*(int)member[M-1][1]-3][0]+=CL[M-1][1]*cos(angles)*S[M-1];//problem

externalforcematrix[3*(int)member[M-1][1]-2][0]+=CL[M-1][1]*cos(angles)*C[M-1];}//problem

else if (BC[3*(int)(member[M-1][1]-1)][0]=1){

externalforcematrix[3*(int)member[M-1][1]-3][0]+=CL[M-1][1]*cos(angles)*S[M-1];//problem

externalforcematrix[3*(int)member[M-1][1]-2][0]+=CL[M-1][1]*cos(angles)*C[M-1];//problem

}

else {

externalforcematrix[3*(int)member[M-1][1]-3][0]+=-CL[M-1][1]*cos(angles)* CL[M-1][0]/length[M-1][0];//problemX方向1点力

externalforcematrix[3*(int)member[M-1][1]-2][0]+=-CL[M-1][1]*cos(angles)*(length[M-1][0]-CL[M-1][0])/length[M-1][0];//problemX方向2点力

}

}

//全距离MOMENT

externalforcematrix[3*(int)member[M-1][0]-1][0]+=(-CL[M-1][0]*CL[M-1][1]*sin(angles)*pow(length[M-1][0]-CL[M-1][0],2)/pow(length[M-1][0],2))*C[M-1];//M1

externalforcematrix[3*(int)member[M-1][1]-1][0]+=(length[M-1][0]-CL[M-1][0])*CL[M-1][1]*sin(angles)*pow(CL[M-1][0],2)/pow(length[M-1][0],2);//M2

//externalforcematrix[3*(int)member[M-1][1]-3][0]+=-CL[M-1][0]*CL[M-1][1]/length[M-1][0];

externalforcematrix[3*(int)member[M-1][0]-2][0]+=-pow(length[M-1][0]-CL[M-1][0],2)*CL[M-1][1]*sin(angles)*(length[M-1][0]+2*CL[M-1][0])/pow(length[M-1][0],2)*C[M-1];//Y1F

externalforcematrix[3*(int)member[M-1][1]-2][0]+=-pow(CL[M-1][0],2)*CL[M-1][1]*sin(angles)*(length[M-1][0]+2*(length[M-1][0]-CL[M-1][0]))/pow(length[M-1][0],2)*C[M-1];//Y2F

//X方向上0力不能算

externalforcematrix[3*(int)member[M-1][0]-3][0]+=-pow(length[M-1][0]-CL[M-1][0],2)*CL[M-1][1]*(length[M-1][0]+2*CL[M-1][0])/pow(length[M-1][0],2)*S[M-1];//X1F

externalforcematrix[3*(int)member[M-1][1]-3][0]+=-pow(CL[M-1][0],2)*CL[M-1][1]*(length[M-1][0]+2*(length[M-1][0]-CL[M-1][0]))/pow(length[M-1][0],2)*S[M-1];//X2F

}

cout<<endl<<"the externalforcematrix is"<<endl;

for(int i=0;i<numberofpoints*3;i++){

cout<<externalforcematrix[0]<<endl;

}

//-------------------MATRIX T, TT--------------------------------------------------------------------

vector<vector<vector<double> > > T;

T.resize(numberofmembers);

for(int i=0;i<numberofmembers;i++){

T.resize(6);

for(int j=0;j<6;j++)

T[j].resize(6,0);

}

vector<vector<vector<double> > > TT;

TT.resize(numberofmembers);

for(int i=0;i<numberofmembers;i++){

TT.resize(6);

for(int j=0;j<6;j++)

TT[j].resize(6);

}

for(int i=0;i<numberofmembers;i++)

for(int j=0;j<6;j++)

for(int k=0;k<6;k++){

T[j][k]=0;

T[j][k]=0;}

vector<vector<double>> s1,s2,s3,s4,s5; //EAL,2EIL,4EIL,6EIL2,12EIL3

s1.resize(numberofmembers);

s2.resize(numberofmembers);

s3.resize(numberofmembers);

s4.resize(numberofmembers);

s5.resize(numberofmembers);

for(int i=0;i<numberofmembers;i++){

s1.resize(1);

s2.resize(1);

s3.resize(1);

s4.resize(1);

s5.resize(1);

}

for(int i=0;i<numberofmembers;i++){

for(int j=0;j<6;j++)

for(int k=0;k<6;k++)

TT[j][k]=T[j][k]=0;

}

for(int i=0,j=1;i<numberofmembers;i++,j++){

int k=(int)member[j-1][1];

int l=(int)member[j-1][0];

double m=coordinate[k-1][1]-coordinate[l-1][1];

double n=coordinate[k-1][0]-coordinate[l-1][0];

s1[0]=((member[j-1][2]*member[j-1][4])/sqrt(pow(m,2)+pow(n,2)));// EA/L

s2[0]=(2*(member[j-1][2]*member[j-1][3])/sqrt(pow(m,2)+pow(n,2)));// 2EIL

s3[0]=(4*(member[j-1][2]*member[j-1][3])/sqrt(pow(m,2)+pow(n,2)));//4EIL

s4[0]=(6*(member[j-1][2]*member[j-1][3])/(pow(m,2)+pow(n,2)));// 6EIL2

s5[0]=(12*(member[j-1][2]*member[j-1][3])/pow(sqrt(pow(m,2)+pow(n,2)),3));// 12EIL3

TT[3][3]=TT[0][0]=T[3][3]=T[0][0]=C;

TT[4][3]=TT[1][0]=T[3][4]=T[0][1]=S;

TT[3][5]=TT[0][2]=T[3][5]=T[0][2]=0;

TT[3][4]=TT[0][1]=T[4][3]=T[1][0]=-S;

TT[4][4]=TT[1][1]=T[4][4]=T[1][1]=C;

TT[4][5]=TT[1][2]=T[4][5]=T[1][2]=0;

TT[5][3]=TT[2][0]=T[5][3]=T[2][0]=0;

TT[5][4]=TT[2][1]=T[5][4]=T[2][1]=0;

TT[5][5]=TT[2][2]=T[5][5]=T[2][2]=1;

}

/* cout<<endl<<"T for member"<<i+1<<" "<<endl;

for(int j=0;j<6;j++){

cout<<" "<<endl;

for(int k=0;k<6;k++){

cout<<T[j][k]<<" ";}}

cout<<endl<<"TT for member"<<i+1<<" "<<endl;

for(int j=0;j<6;j++){

cout<<" "<<endl;

for(int k=0;k<6;k++){

cout<<TT[j][k]<<" ";}

*/

//---------------------small matrix----------------------------------------------------------------------------

vector<vector<double>>K;

K.resize(6);

for(int i=0;i<6;i++)

K.resize(6);

vector<vector<vector<double>>> smallmatrix1;

smallmatrix1.resize(numberofmembers);

for(int i=0;i<numberofmembers;i++){

smallmatrix1.resize(6);

for(int j=0;j<6;j++)

smallmatrix1[j].resize(6);

}

vector<vector<vector<double>>> smallmatrix2;

smallmatrix2.resize(numberofmembers);

for(int i=0;i<numberofmembers;i++){

smallmatrix2.resize(6);

for(int j=0;j<6;j++)

smallmatrix2[j].resize(6);

}

for(int i=0;i<numberofmembers;i++){

K[0][0]=s1[0];

K[0][1]=0;

K[0][2]=0;

K[0][3]=-s1[0];

K[0][4]=0;

K[0][5]=0;

K[1][0]=0;

K[1][1]=s5[0];

K[1][2]=s4[0];

K[1][3]=0;

K[1][4]=-s5[0];

K[1][5]=s4[0];

K[2][0]=0;

K[2][1]=s4[0];

K[2][2]=s3[0];

K[2][3]=0;

K[2][4]=-s4[0];

K[2][5]=s2[0];

K[3][0]=-s1[0];

K[3][1]=0;

K[3][2]=0;;

K[3][3]=s1[0];

K[3][4]=0;

K[3][5]=0;

K[4][0]=0;

K[4][1]=-s5[0];

K[4][2]=-s4[0];

K[4][3]=0;

K[4][4]=s5[0];

K[4][5]=-s4[0];

K[5][0]=0;

K[5][1]=s4[0];

K[5][2]=s2[0];

K[5][3]=0;

K[5][4]=-s4[0];

K[5][5]=s3[0];

for(int j=0;j<6;j++)

for(int k=0;k<6;k++)

smallmatrix1[j][k]=K[j][k];

/* cout<<"smallmatrix1 value is "<<endl;

for(int j=0;j<6;j++){

cout<<" "<<endl;

for(int k=0;k<6;k++)

cout<<smallmatrix1[k][j]<<" ";}*/

if (coordinate[((int)member[1])-1][1]!=coordinate[((int)member[0]-1)][1])

{

vector<vector<vector<double>>> middle;

middle.resize(numberofmembers);

for(int j=0;j<numberofmembers;j++){

middle[j].resize(6);

for(int k=0;k<6;k++)

middle[j][k].resize(6);

}

//=================================================================================

for(int j= 0;j<=5; j++)

for (int k= 0;k<=5; k++)

for(int p = 0; p <=5; p++)

middle[j][k] += TT[j][p] * smallmatrix1[p][k];//乘法

/* cout<<"middle value is "<<endl;

for(int j=0;j<6;j++){

cout<<" "<<endl;

for(int k=0;k<6;k++){

cout<<middle[j][k]<<" ";}}*/

//=================================================================================

for(int j= 0;j<=5; j++)

for (int k= 0;k<=5; k++)

for(int p = 0; p <=5; p++)

smallmatrix2[j][k] += middle[j][p] * T[p][k];//乘法

for(int j=0;j<6;j++)

for(int k=0;k<6;k++)

smallmatrix1[j][k]=smallmatrix2[j][k];

//=================================================================================

/* cout<<"smallmatrix2 value is "<<endl;

for(int j=0;j<6;j++){

cout<<" "<<endl;

for(int k=0;k<6;k++)

cout<<smallmatrix2[j][k]<<" ";}*/

//=================================================================================

}

}

cout<<endl<<"small Matrix is "<<endl;

for(int i=0;i<numberofmembers;i++){

cout<<endl<<" member "<<i+1<<" "<<endl;

for(int j=0;j<6;j++){

cout<<" "<<endl;

for(int k=0;k<6;k++)

cout<<setprecision(3)<<smallmatrix1[j][k]<<" ";}}

//---------------------big matrix----------------------------------------------------------------------------

vector<vector<double>> bigmatrix;

bigmatrix.resize(3*numberofpoints);

for(int i=0;i<3*numberofpoints;i++)

bigmatrix.resize(3*numberofpoints);

for(int j=0;j<numberofpoints*3;j++){

for(int k=0;k<numberofpoints*3;k++)

bigmatrix[j][k]=0;

}

for(int i=0,p,q;i<numberofmembers;i++){

p=(int)member[0];

q=(int)member[1];

for(int j=(p-1)*3,l=0;j<=p*3-1;j++,l++)

for(int k=(p-1)*3,n=0;k<=p*3-1;k++,n++)

bigmatrix[j][k]+=smallmatrix1[l][n];

for(int j=(p-1)*3,l=0;j<=p*3-1;j++,l++)

for(int k=(q-1)*3,n=3;k<=q*3-1;k++,n++)

bigmatrix[j][k]+=smallmatrix1[l][n];

for(int j=(q-1)*3,l=3;j<=q*3-1;j++,l++)

for(int k=(p-1)*3,n=0;k<=p*3-1;k++,n++)

bigmatrix[j][k]+=smallmatrix1[l][n];

for(int j=(q-1)*3,l=3;j<=q*3-1;j++,l++)

for(int k=(q-1)*3,n=3;k<=q*3-1;k++,n++)

bigmatrix[j][k]+=smallmatrix1[l][n];

}

cout<<endl;

cout<<endl<<"big matrix is "<<endl;

for(int i=0;i<3*numberofpoints;i++){

cout<<" "<<endl;

for(int j=0;j<3*numberofpoints;j++)

cout<<setprecision(3)<<bigmatrix[j]<<" ";}

//===========================final band width matrix==================================

cout<<endl;

cout<<endl<<"final answer matrix"<<endl;

for(int i=0;i<3*numberofpoints;i++){

cout<<" "<<endl;

if((3*numberofpoints-i)>3*bandwidth)

for(int j=i;j<(i+3*bandwidth);j++)

cout<<bigmatrix[j]<<" ";

else for(int j=i,k=0;k<(3*numberofpoints-i);j++,k++)

cout<<bigmatrix[j]<<" ";

}

//=================================number of BC=====================================================================

vector<vector<double>> finalresult2;

finalresult2.resize(numberofBC);

for(int i=0;i<numberofBC;i++)

finalresult2.resize(numberofBC);

for(int i=0,p=-1;i<3*numberofpoints;i++){

if(BC[0]!=0){

p++;

for(int j=0,q=-1;j<3*numberofpoints;j++)

if(BC[0]!=0&&BC[j][0]!=0){

q++;

finalresult2[p][q]=bigmatrix[j];}

}}

//---------------------inverse matrix----------------------------------------------------------------------------

/*****************扩展矩阵***********************/

vector<vector<double>> b;

b.resize(numberofBC);

for(int i=0;i<numberofBC;i++)

b.resize(2*numberofBC);

for(int i=0;i<numberofBC;i++)

for(int j=0;j<2*numberofpoints;j++)

b[j]=0;

vector<vector<double>>result;

result.resize(numberofBC);

for(int i=0;i<numberofBC;i++)

result.resize(numberofBC);

for(int i=0;i<numberofBC;i++)

{

for(int j=0;j<numberofBC;j++)

{

b[j]=finalresult2[j];

}

}

int i,j,k;

for(i=0;i<numberofBC;i++)

{

for(j=numberofBC;j<2*numberofBC;j++)

{

if(i==(j-numberofBC))

{

b[j]=1;

}

else

{

b[j]=0;

}

}

}

/*****************扩展矩阵***********************/

/*****************求逆模块***********************/

for(i=0;i<numberofBC;i++)

{

if(b==0)

{

for(k=i;k<numberofBC;k++)

{

if(b[k][k]!=0)

{

for(int j=0;j<2*numberofBC;j++)

{

double temp;

temp=b[j];

b[j]=b[k][j];

b[k][j]=temp;

}

break;

}}

}

for(j=2*numberofBC-1;j>=i;j--)

{if(b!=0)

b[j]/=b;

}

for(k=0;k<numberofBC;k++)

{

if(k!=i)

{

double temp=b[k];

for(j=0;j<2*numberofBC;j++)

{

b[k][j]-=temp*b[j];

}

}

}

}

/*****************求逆模块***********************/

/*****************导出结果***********************/

for(i=0;i<numberofBC;i++)

{

for(j=numberofBC;j<2*numberofBC;j++)

{

result[j-numberofBC]=b[j];

}

}

/*****************导出结果***********************/

cout<<endl<<"the inverse matrix is "<<endl;

for(i=0;i<numberofBC;i++)

{

for(j=0;j<numberofBC;j++)

{

cout<<result[j]<<" ";

}

cout<<endl;

}

//---------------------f=LU matrix----------------------------------------------------------------------------

vector<vector<double>> matrixL;

matrixL.resize(3*numberofpoints);

for(int i=0;i<3*numberofpoints;i++)

matrixL.resize(3*numberofpoints);

vector<vector<double>>matrixU;

matrixU.resize(3*numberofpoints);

for(int i=0;i<3*numberofpoints;i++)

matrixU.resize(3*numberofpoints);

for(int i=0;i<numberofpoints*3;i++)

for(int j=0;j<numberofpoints*3;j++){

matrixU[j]=0;

matrixL[j]=0;}

//==================================LUDcomposition=============================================================================

//LUDcomposition(bigmatrix,matrixL,matrixU,3*numberofpoints);

vector<vector<double>>matrixA1;

matrixA1.resize(3*numberofpoints);

for( int i=0;i<3*numberofpoints;i++)

matrixA1.resize(3*numberofpoints);

for(int i=0;i<3*numberofpoints;i++)

for(int j=0;j<3*numberofpoints;j++)

matrixA1[j] = bigmatrix[j];

for (int i=1;i<3*numberofpoints;i++)

for(int j=0;j<i;j++)

matrixU[j] = 0;

for(int i=0;i<3*numberofpoints;i++){

matrixL=1;

for(int j=i+1;j<3*numberofpoints;j++)

matrixL[j] = 0;}

for(int k = 0; k < 3*numberofpoints; k++)

{

matrixL[k][k]=matrixU[k][k] = sqrt(matrixA1[k][k]);

for (int i = k+1; i < 3*numberofpoints; i++){

matrixL[k] = matrixA1[k] /matrixU[k][k];

matrixU[k] = matrixA1[k];}

for (int i = k+1; i <3*numberofpoints; i++)

for (int j = k+1; j <3*numberofpoints; j++)

matrixA1[j] = matrixA1[j] - matrixL[k] * matrixU[k][j];

}

//=============================================================================================

cout<<endl<<"MatrixL "<<endl;

for(int i=0;i<3*numberofpoints;i++){

cout<<" "<<endl;

for(int j=0;j<3*numberofpoints;j++)

cout<<setprecision(3)<<1000*matrixL[j]<<" ";}

cout<<endl<<"MatrixU is "<<endl;

for(int i=0;i<3*numberofpoints;i++){

cout<<" "<<endl;

for(int j=0;j<3*numberofpoints;j++)

cout<<setprecision(3)<<1000*matrixL[j]<<" ";

}

//-----------------------------------small part for final answer-------------------------------------------------------------------------

//---------------------finalresult----------------------------------------------------------------------------

vector<vector<double>> tempfinalresult;

tempfinalresult.resize(3*numberofpoints);

for(int i=0;i<3*numberofpoints;i++)

tempfinalresult.resize(1);

vector<vector<double>>tempexternalforcematrix;

tempexternalforcematrix.resize(numberofBC);

for(int i=0;i<numberofBC;i++)

tempexternalforcematrix.resize(1);

vector<vector<double>> finalresult;

finalresult.resize(numberofBC);

for(int i=0;i< numberofBC;i++)

finalresult.resize(1);

for(int j= 0;j<3*numberofpoints; j++)

tempfinalresult[j][0]=tempfinalresult[j][0]-conditionmatrix[j][0];

for(int j= 0,i=-1;j<3*numberofpoints; j++){

if(BC[j][0]!=0){

i++;

finalresult[0]=tempfinalresult[j][0];

tempexternalforcematrix[0]=externalforcematrix[j][0];}}

for(int j= 0;j<numberofBC; j++){

for(int p = 0; p <numberofBC; p++)

finalresult[j][0] +=result[j][p]*tempexternalforcematrix[p][0];}//乘法

cout<<endl;

//=================================number of BC=====================================================================

for(int i=0;i<3*numberofpoints;i++){

if(BC[0]!=0){

if((i+3)%3==0) cout<<"d"<<i+1<<"x= "<<endl;

else if((i+2)%3==0) cout<<"d"<<i+1<<"y= "<<endl;

else if ((i+1)%3==0) cout<<"@"<<i+1<<"= "<<endl;

}

}

for(int i=0;i<numberofBC;i++)

cout<<finalresult[0]<<endl;

//-----------------------------------------------------------------------------------------------

char all;

cout<<endl<<"all right?"<<endl;

cin>>all;

if(all=='r')

return 0;

else

cout<<endl<<"the password is wrong!!"<<endl;

return 0;

}

//------------------------------------------------------------------------

/*

void LUDcomposition(vector<vector<double>> matrixA,vector<vector<double>> &matrixL,vector<vector<double>>& matrixU, int size){

int i,j,k;

vector<vector<double>>matrixA1;

matrixA1.resize(size);

for( i=0;i<size;i++)

matrixA1.resize(size);

for(i=0;i<size;i++)

for(j=0;j<size;j++)

matrixA1[j]=0;

for(i=0;i<size;i++)

for(j=0;j<size;j++)

matrixA1[j] = matrixA[j];

for (i=1;i<size;i++)

for(j=0;j<i;j++)

matrixU[j] = 0;

for(i=0;i<size;i++)

{

matrixL = 1;

for(j=i+1;j<size;j++)

matrixL[j] = 0;

}

for(int i=1;i<size;i++)

for(int j=0;j<i;j++){

matrixU[j]=0;

matrixL[j]=0;}

for(k = 0; k < size; k++)

{

matrixU[k][k] = matrixA1[k][k];

for (i = k+1; i < size; i++)

{

matrixL[k] = matrixA1[k] /matrixU[k][k];

matrixU[k] = matrixA1[k];

}

for (i = k+1; i < size; i++)

for (j = k+1; j < size; j++)

matrixA1[j] = matrixA1[j] - matrixL[k] * matrixU[k][j];

}

}

*/




==========
这个是专业课的一个作业,就是输入一部分指令数据进行10*10的结构力学的矩阵算法
用C++编写的..教授说太长了……
如何可以简化类.....?
其实我C++自学的,所以很多地方是全假设全编写……就冗长很多

[此贴子已经被作者于2010-6-27 11:21:26编辑过]

105

主题

2万

帖子

1万

积分

版主

山口山NEET姬

威望
15
帅气
29
聪明
1
强壮
2
美丽
7
可爱
45
星沙
6
金钱
92241
发表于 2010-6-27 11:15:00 | 显示全部楼层
瞬间我以为中病毒了= =

1w2mop是什么。。。
Gloria! Oh...Gloria! Sound Horizon Kingdom! Gloria! Oh...Gloria! Sound Horizon Kingdom! Oh...Oh...Gloria!
回复 支持 反对

使用道具 举报

92

主题

9038

帖子

9382

积分

版主

Youth

威望
15
帅气
26
聪明
24
强壮
1
美丽
158
可爱
21
星沙
0
金钱
149930
 楼主| 发表于 2010-6-27 11:17:00 | 显示全部楼层
= = 1W2 澳门币..大概1W+RMB吧
那些是C++指令啦..
回复 支持 反对

使用道具 举报

37

主题

2万

帖子

1万

积分

版主

这样也不错

威望
0
帅气
15
聪明
0
强壮
3
美丽
0
可爱
33
星沙
0
金钱
133459
发表于 2010-6-27 11:17:00 | 显示全部楼层

打到TH分装备
这程序 果然好繁琐

回复 支持 反对

使用道具 举报

105

主题

2万

帖子

1万

积分

版主

山口山NEET姬

威望
15
帅气
29
聪明
1
强壮
2
美丽
7
可爱
45
星沙
6
金钱
92241
发表于 2010-6-27 11:21:00 | 显示全部楼层
好砖液。。。0 0
好多钱。。。+ +

至今还没赚到人参的第一桶金啊~T T

如果不算上小学时期倒卖贴画赚的部分的话。。。
Gloria! Oh...Gloria! Sound Horizon Kingdom! Gloria! Oh...Gloria! Sound Horizon Kingdom! Oh...Oh...Gloria!
回复 支持 反对

使用道具 举报

92

主题

9038

帖子

9382

积分

版主

Youth

威望
15
帅气
26
聪明
24
强壮
1
美丽
158
可爱
21
星沙
0
金钱
149930
 楼主| 发表于 2010-6-27 11:23:00 | 显示全部楼层
以下是引用枫灵knight在2010-6-27 11:17:00的发言:

打到TH分装备
这程序 果然好繁琐

泪目
熬了7个晚上啊7个晚上…………

回复 支持 反对

使用道具 举报

37

主题

2万

帖子

1万

积分

版主

这样也不错

威望
0
帅气
15
聪明
0
强壮
3
美丽
0
可爱
33
星沙
0
金钱
133459
发表于 2010-6-27 11:24:00 | 显示全部楼层
太长了吧
这题目是什么
回复 支持 反对

使用道具 举报

80

主题

4万

帖子

3万

积分

贵宾

僵尸⑥

威望
6
帅气
119
聪明
0
强壮
104
美丽
27
可爱
32
星沙
1
金钱
31170
发表于 2010-6-27 11:25:00 | 显示全部楼层
好厉害!
我只不过是一个被赋予了运动、情感和思想的“宇宙力机器”。
回复 支持 反对

使用道具 举报

13

主题

2万

帖子

2万

积分

精英

人家真的只是一只路过的大叔而已啦>///<

威望
0
帅气
32
聪明
70
强壮
23
美丽
12
可爱
82
星沙
0
金钱
79086
发表于 2010-6-27 11:25:00 | 显示全部楼层
日西什么的最讨厌了T T
回复 支持 反对

使用道具 举报

105

主题

2万

帖子

1万

积分

版主

山口山NEET姬

威望
15
帅气
29
聪明
1
强壮
2
美丽
7
可爱
45
星沙
6
金钱
92241
发表于 2010-6-27 11:28:00 | 显示全部楼层
土豪接下来就会进化成后宫男了。。。
Gloria! Oh...Gloria! Sound Horizon Kingdom! Gloria! Oh...Gloria! Sound Horizon Kingdom! Oh...Oh...Gloria!
回复 支持 反对

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|PMGBA ( 闽ICP备06006686号  

GMT+8, 2016-12-9 12:06 , Processed in 0.501878 second(s), 34 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表