Inversion of sparse matrices (normal inversion and normal inversion)

Source: Internet
Author: User

#include "stdafx.h" #include <iostream>using namespace std;typedef int DataType; #define SIZE 100typedef Struct{int I,j;datatype e;} Triple;typedef struct{triple data[size+1];int Mu,nu,tu;} Tsmatrix;void transpose (Tsmatrixm,tsmatrix &t) {//interchange row number t.mu = M.tu; t.nu = m.mu; T.tu = M.tu;if (t.tu) {int q = 1;for (int col =1;col<m.nu;++col) {for (int p=1;p<m.tu;++p) {if (m.data[p].j = col) {T.data [Q].I = M.DATA[P].J; T.DATA[Q].J = m.data[p].i; T.DATA[Q].E = M.data[p].e;++q;}}}}    void Input1 (Tsmatrix &m) {printf ("Input nu mu tu (with a space interval) of a matrix:\n");  scanf_s ("%d%d%d", m.nu,m.mu,m.tu);    Row,colume,and tu printf ("Please input the data of matrix:\n");          for (int c=1;c<=m.tu;c++) {scanf_s ("%d", &m.data[c].i);           scanf_s ("%d", &AMP;M.DATA[C].J);       scanf_s ("%d", &AMP;M.DATA[C].E);    }//for}int Printm (Tsmatrix T) {printf ("Matrix after transpose is:\n"); for (int c=1;c<=t.tu;c++) {printf ("%d%d%d\n", T.data[c].i,t.data[C].J,T.DATA[C].E];    }//for return 1; }//input void Fasttranspose (Tsmatrix m,tsmatrix &t) {//interchange row number t.mu = M.tu; t.nu = m.mu; T.tu = M.tu;int cpot[size+1],num[size+1];if (m.tu) {for (int col=1;col<m.mu;col++) num[col]=0;for (int t=1;t<M.tu; t++) ++num[m.data[t].j];cpot[1] = 1;for (int col=2;col<m.mu;col++) cpot[col]=cpot[col-1]+num[col-1];for (int p=1;p <m.tu;++p) {int col = m.data[p].j;int q = cpot[col];              T.DATA[Q].I=M.DATA[P].J;              T.DATA[Q].J=M.DATA[P].I;              T.DATA[Q].E=M.DATA[P].E;  ++cpot[col]; }}}/*void Main () {Tsmatrix M; Tsmatrix t;input1 (M); Fasttranspose (m,t); Printm (M);} */

  

Inversion of sparse matrices (normal inversion and normal inversion)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.