Implementation of sparse matrix multiplication operator based on C + +

Source: Internet
Author: User

1. Description of the problem

Sparse matrices are those matrices where most of the elements are zeros. The use of "sparse" features for storage and calculation can greatly save storage space and improve computational efficiency. To implement a sparse matrix multiplication operation of the operator. The sparse matrix is represented by the ternary order table with "Logical link information" to realize the multiplication of two matrices. The sparse matrix is represented by a cross linked list, and the matrix of the result of the operation is listed in the usual array form

2 Design

2.1 Using a cross linked list to store sparse matrices

In order to effectively store the sparse matrix elements, this paper uses a cross linked list of data storage, the design of the cross-linked list of C + + language described below:

Typedef struct OLNode{

Int  i , j ;

ElemType e;

Struct OLNode * right, * down;

}OLNode; *OLink;

Typedef struct{

OLink * rhead, * chead;

      Int  mu,nu,tu;

}CrossList;

The main algorithm design of 2.2 sparse matrix multiplication

Sparse matrix multiplication operator design is mainly designed to the sparse matrix creation and multiplication operations, the following given the two procedures of C + + language described as:

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.