Design an abstract data type for a matrix with integer elements in a language that you know, including operations for addition, subtraction, and matrix multiplication. Can any one help me towrite this programme in F# language using visual studio 2019.
An abstract data type (ADT) is an object with a generic description independent of implementation details. This description includes a specification of the components from which the object is made and also the behavioral details of the object. Instances of abstract objects include mathematical objects (like numbers, polynomials, integrals, vectors), physical objects (like pulleys, floating bodies, missiles), animate objects (dogs, Pterodactyls, Indians) and objects (like poverty, honesty, inflation) that are abstract even in the natural language sense.
In order to define an ADT we need to specify:
There may be thousands of ways in which a given ADT can be implemented, even when the coding language remains constant. Any such implementation must comply with the content-wise and behavioral description of the ADT.
Examples
For example:-
for a complex number:-
typedef struct { double real; double imag; } complex;
//addition can be performed
complex cadd ( complex z1 , complex z2 ) { complex z; z.real = z1.real + z2.real; z.imag = z1.imag + z2.imag; return z; }
//subtraction can be performed
complex csub ( complex z1 , complex z2 ) { complex z; z.real = z1.real - z2.real; z.imag = z1.imag - z2.imag; return z; }
void cprn ( complex z ) { printf("(%lf) + i(%lf)", z.real, z.imag); }
for the matrix:-
#define MAXROW 10 #define MAXCOL 15 typedef struct { int rowdim; int coldim; complex entry[MAXROW][MAXCOL]; } matrix;
matrix madd ( matrix A , matrix B ) //addition { matrix C; int i, j; if ((A.rowdim != B.rowdim) || (A.coldim != B.coldim)) { fprintf(stderr, "madd: Matrices of incompatible dimensions\n"); C.rowdim = C.coldim = 0; return C; } C.rowdim = A.rowdim; C.coldim = A.coldim; for (i = 0; i < C.rowdim; ++i) for (j = 0; j < C.coldim; ++j) C.entry[i][j] = cadd(A.entry[i][j],B.entry[i][j]); return C; }
matrix msub ( matrix A , matrix B ) { matrix C; int i, j; if ((A.rowdim != B.rowdim) || (A.coldim != B.coldim)) { fprintf(stderr, "madd: Matrices of incompatible dimensions\n"); C.rowdim = C.coldim = 0; return C; } C.rowdim = A.rowdim; C.coldim = A.coldim; for (i = 0; i < C.rowdim; ++i) for (j = 0; j < C.coldim; ++j) C.entry[i][j] = csub(A.entry[i][j],B.entry[i][j]); return C; }
Design an abstract data type for a matrix with integer elements in a language that you...
Hi can any one help me with this programme to translating in F# language using visual studio. //Include the required header files. #include //Define the main() function. int main() { //Declare the required variables. int x,y; //Prompt the user to enter the input. printf(“Enter the value of x : “); scanf(“%d”,&x); //Check the value of x and set the value of y. if(x>10) { y=x; } if(x<5) { y=x*2; } if(x==7) { y=x+10; } //Display the value of y. printf(“\nThe...
In C++
Design a class to perform various matrix operations. A matrix is a set of numbers arranged in rows and columns. Therefore, every element of a matrix has a row position and a column position. If A is a matrix of five rows and six columns, we say that the matrix A is of the size 5 X 6 and sometimes denote it as Asxc. Clearly, a convenient place to store a matrix is in a two-dimensional array. Two...
The assignment In this assignment you will take the Matrix addition and subtraction code and modify it to utilize the following 1. Looping user input with menus in an AskUserinput function a. User decides which operation to use (add, subtract) on MatrixA and MatrixB b. User decides what scalar to multiply MatrixC by c. User can complete more than one operation or cancel. Please select the matrix operation 1- Matrix Addition A+ B 2-Matrix Subtraction A-B 3Scalar Multiplication sC 4-Cancel...
It is required to write a Matrix Calculator Program using C Programming Language that could only perform addition, subtraction, and multiplication of two matrices of appropriate dimensions. Your program should prompt the user to select a matrix operation from a list of options that contains the aforementioned operations. Then, the user should be prompted to enter the dimensions of the two operand matrices. Next, your program should prompt the user to enter the elements of each matrix row-wise. Your program...
write in C++ polynomial class that the data type of the coefficients is a template parameter. This data type can be any type that has operators for addition, subtraction multiplication and assignment. The class should have a default constructor which results in a zero value. For example our template class would allow us to build polynomails where coefficients are complex numbers ( using the complex<double> type < complex>)
To understand Parnas partitioning, consider writing a module to
implement an abstract data type called a stack with associated
operations PUSH and POP. The implementation of this module should
be hidden from all calling modules. A data item should be passed to
the PUSH procedure with assurance that it will be placed on the
stack. Similarly, the POP procedure should return a data item from
the stack and adjust the stack accordingly. Access to the stack in
memory via any...
Problem 3 (20 pts) It is required to write a Matrix Calculator Program using C Programming Language that could only perform addition, subtraction, and multiplication of two matrices of appropriate dimensions. Your program should prompt the user to select a matrix operation from a list of options that contains the aforementioned operations. Then, the user should be prompted to enter the dimensions of the two operand matrices. Next, your program should prompt the user to enter the elements of each...
OUTCOMES After you finish this assignment, you will be able to do the following: Define an abstract class Create concrete classes from an abstract class Overload an operator Split classes into .h and .cpp files Open files for reading Write to files Use output manipulators such as setw, fixed, and setprecision DESCRIPTION A binary arithmetic operation takes two double operands (left and right) to perform addition, subtraction, multiplication, or division on. For example, 10 + 11 is an addition (+)...
With this program you are going to design a math practice program for younger users. You will ask the user to enter two numbers. Only numbers may be entered. If the user enters a word, the program should disregard the entry and wait for an integer entry. There will not be another prompt if the user enters data other than whole numbers (integers). Here is a sample run: Your static methods should accept two integers and return an integer. Do...
Please code in C++.
link to continue the code is this below or you can make your
own code if you wish(fix any mistakes if you think there are any in
it):
cpp.sh/3qcekv
3. Submit a header file (project3.h), a definition file (project3.cpp), a main file (main.cpp), and a makefile to compile them together. Make sure to run the command make and produce an application file and include it with your submission. For this project, you are required to create...