#include <iostream>
using namespace std;
class matrices
{
public:
void set(int i,int j,double v){
x[i][j]=v;
}
double get(int i,int j){
return x[i][j];
}
double add(double y[2][2]){
for(int i=0;i<2;i++){
for(int
j=0;j<2;j++){
x[i][j]+=y[i][j];
}
}
}
double multiply(double y[2][2]){
int sum=0;
for (int c = 0; c < 2; c++) {
for (int d = 0; d < 2; d++)
{
for (int k = 0; k <
2; k++) {
sum = sum +
x[c][k]*y[k][d];
}
mul[c][d] =
sum;
sum = 0;
}
}
}
double det(double x[2][2]){
double deter =
x[0][0]*x[1][1]-x[0][1]*x[1][0];
return deter;
}
matrices(){
for(int i=0;i<2;i++){
for(int
j=0;j<2;j++){
x[i][j]=0;
}
}
}
matrices(double y[2][2]){
for(int i=0;i<2;i++){
for(int
j=0;j<2;j++){
x[i][j]=y[i][j];
}
}
}
private:
double x[2][2];
double mul[2][2];
};
int main(){
matrices mat;
double y[2][2],x[2][2];
cout<<"enter the matrix x (2x2) : "<<endl;
for(int i=0;i<2;i++){
for(int
j=0;j<2;j++){
cin>>x[i][j];
}
}
cout<<"enter the matrix y (2x2) :
"<<endl;
for(int i=0;i<2;i++){
for(int
j=0;j<2;j++){
cin>>y[i][j];
}
}
mat.add(y);
mat.multiply(y);
cout<<"determinant of matrix X is "<<mat.det(x)<<endl;
return 0;
}
Topic Ch. 10 : Write a class definition for a 2x2 matrix, with methods for get(i,j),...
****C PROGRAMMING**** Why isn't the determinant part of my code not running? I have included the attachments below and would greatly appreciate some help. --------------------------------------- case 6: printf("You chose determinate!\n\n"); printf("Press 2 for 2x2\n OR \n Press 3 for 3x3 Matrix: "); scanf("%d", &detChoice); printf("\n"); if (detChoice == 2) { printf("Matrix: ");...
Using java fix the code I implemented so that it passes the JUnit Tests. MATRIX3 public class Matrix3 { private double[][] matrix; /** * Creates a 3x3 matrix from an 2D array * @param v array containing 3 components of the desired vector */ public Matrix3(double[][] array) { this.matrix = array; } /** * Clones an existing matrix * @param old an existing Matrix3 object */ public Matrix3(Matrix3 old) { matrix = new double[old.matrix.length][]; for(int i = 0; i <...
I'm having trouble sorting this square matrix (a 2d array that has number of rows and same number of column n x n) using row-wise approach in C programming. Please help me program this in C to sort it using row-wise approach, here is the code: #include <stdio.h> #define MAX 100 int main() { int mat[MAX][MAX]; int i, j, m, n; int rowsum, columnsum, diagonalsum; int k; int magic = 0; int transpose[MAX][MAX]; printf("Enter the # of rows and columns...
Using separate files, write the definition for a class called Point and a class called Circle. The class point has the data members x (double) and y (double) for the x and y coordinates. The class has the following member functions: a) void set_x(double) to set the x data member b) void set_y(double) to set the y data member c) double get_x() to return the the x data member d) double get_y() to return the the y data member e)...
need help with e f and g please 2x2 + x3 0 (1 pts) write the linear system in the format, A x = b (2 pts) Find the determinant of the matrix A by using an expansion along row 1 (2 pts) Find the determinant of the matrix A by using an expansion along column 2 Compare the result with that of (b). Based on your result of b and/or c is matrix A singular or invertible (2 pts)...
Given a matrix, clockwise-rotate elements in it. Please add code to problem3.cpp and the makefile. I have also given the main_problem3.cpp and problem3.h to test. problem3.cpp::: #include "problem3.h" // A function to rotate a matrix mat[][MAX] void rotatematrix(int m, int n, int mat[][MAX]) { // your code here } Makefile::: all : problem3.o g++ -o mainp3 # your code here problem3.o : problem3.h problem3.cpp # your code here clean: rm -f *.o mainp3 main_problem3.cpp::: #include <iostream>...
PLEASE help! There should be three files a (.h file), a (main.cpp file), and a (test.cpp file) please do not miss any of the questions!! I'm going to try this myself too thanks for any and all help Write a class called array2x2 which includes the following members: Private members: o A two dimensional array to store the data: double data[2][2]; Public members: o A default constructor which initializes data to having entries all 0. [i.e., data[i][j]=0.0 for all i...
Problem: Matrix Implementation Create a class Matrix with the following method stubs for the following methods described: 1. read: reads in a matrix from the command line 2. display: prints the matrix to the command line 3. getRows: returns the number of rows 4. getCols: returns the number of columns 5. set: sets the double value at a particular column/row position 6. get: returns the value stored at a particular column/row position 7. Plus: returns a new Matrix object that...
I need help modifying this program. How would I make sure that the methods is being called and checked in my main method? Here is what the program needs to run as: GDVEGTA GVCEKST The LCS has length 4 The LCS is GVET This is the error that I'm getting: The LCS has length 4 // I got this right The LCS is //the backtrace is not being called for some reason c++ code: the cpp class: /** * calculate...
Language is C++ Basic principles and theory of structured programming in C++ by implementing the class: Matrix Use these principles and theory to help build and manipulate instances of the class (objects), call member functions Matrix class implementation from the main function file and, in addition, the Matrix class must have its interface(Matrix.h) in a separate file from its implementation (Matrix.cpp). The code in the following files: matrix.h matrix.cpp matrixDriver.h Please use these file names exactly. Summary Create three files...