Class-project < Matrix >

Source: Internet
Author: User

Design a fairly well-packaged matrix class (easy to use)

(mainly at that time the matrix with the struct write, now feel good rotten.) In fact, the use of struct writing is mainly using his = number assignment directly copy memory block, written as class, but also a few more constructors ... )

Right as one of your own class design exercises (my oop design sucks ...) ), estimated time of completion: variable (I will try to spare time to update)

< Here are some of the ways to think for yourself >

You don't have a template? , and the template may actually be a bit slow to write, so I use TypeDef matrixdatatype, which may affect the use of certain situations? For example, make a member of a matrix with a large number: (Well, after this, I have to have time to read the template.)

Because it is used for ACM, I consider the use of vectors to achieve the matrix, dynamic allocation of memory, it is not difficult to write, mainly afraid of speed can not keep up with

But there is still a problem, vector internal implementation is the application of an entire block of memory, if the memory block is not installed, then open a new, then the old copy past, that is, there may be adjustments to the cost O (r*c)

So I'm going to design it in two ways, one that specifies the size of the r,c (so that's not going to happen), one that is not specified (which may have an effect on speed)

After the operator all overloaded, division sign words also overloaded it.

< R,c, start with 0.

Initialize the words:

1. Initialize to a diagonal matrix

2. Initialize the 0 matrix

Modified words

1. Change a column of a row to a number

2. Add a value to all elements on line "L,r"

3. Add all the elements on the "l,r" column to a value

Other methods:

1. Get the current number of rows

2. Get the current number of columns

The first two are OOP requirements, after all, to be sealed into private

3. Add a line to the vector reference and check that the column is aligned

4. Add a column, with a reference to the vector, to check if the number of rows is met

5. Fast power, overload two methods, one is need mod, one is not need mod.

6. Output a row of the and

7. Outputs a column of the and

For the time being, if you have any ideas, you can reply to me below.

Current completion Progress: 0

----------------------Code-----------------------------

Class-project < Matrix >

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.