-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatrix.java
89 lines (79 loc) · 2.51 KB
/
Matrix.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
WeChat: cstutorcs
QQ: 749389476
Email: tutorcs@163.com
/**
* A simple matrix ADT.
*
* Last updated 7/31/2021.
*
*/
package edu.ser222.m01_02;
public interface Matrix {
/**
* Returns the element at particular point in the matrix.
* @param y y position
* @param x x position
* @return element
*/
public int getElement(int y, int x);
/**
* Returns the number of rows in the matrix.
* @return rows
*/
public int getRows();
/**
* Returns the number of columns in the matrix.
* @return columns
*/
public int getColumns();
/**
* Returns this matrix scaled by a factor. That is, computes kA where k is a
* constant and A is a matrix (this object).
*
* @param scalar scalar
* @return matrix
*/
public Matrix scale(int scalar);
/**
* Returns this matrix added with another matrix. That is, computes A+B
* where A and B are matrices (this object, and another respectively).
* @param other addend
* @return matrix
* @throws RuntimeException if matrices do not have matching dimensions.
* @throws IllegalArgumentException if other matrix is null.
*/
public Matrix plus(Matrix other);
/**
* Returns this matrix subtracted by another matrix. That is, computes A-B
* where A and B are matrices (this object, and another respectively).
* @param other subtrahend
* @return matrix
* @throws RuntimeException if matrices do not have matching dimensions.
* @throws IllegalArgumentException if other matrix is null.
*/
public Matrix minus(Matrix other);
/**
* Returns this matrix multiplied by another matrix (using dot products).
* That is, computes AB where A and B are matrices (this object, and another
* respectively).
* @param other multiplicand
* @return matrix
* @throws RuntimeException if matrices do not have appropriate dimensions.
* @throws IllegalArgumentException if other matrix is null.
*/
public Matrix multiply(Matrix other);
/**
* Returns true if this matrix matches another matrix.
* @param other another matrix
* @return equality
*/
@Override
public boolean equals(Object other);
/**
* Returns a string representation of this matrix. A new line character will
* separate each row, while a space will separate each column.
* @return string representation
*/
@Override
public String toString();
}