Question: use std::{ops, fmt}; #[derive(PartialEq, Debug)] pub struct Matrix { /// Stores elements in [row-major order](https://en.wikipedia.org/wiki/Row-major_order) data: Vec , /// Number of rows row: usize, ///

use std::{ops, fmt}; #[derive(PartialEq, Debug)] pub struct Matrix { /// Stores elements in [row-major order](https://en.wikipedia.org/wiki/Row-major_order) data: Vec, /// Number of rows row: usize, /// Number of columns col: usize, } impl Matrix { /// Creates a new matrix of `row` rows and `col` columns, and initializes /// the matrix with the elements in `values` in row-major order. pub fn new(row: usize, col: usize, values: &[T]) -> Matrix { unimplemented!(); } /// Creates a new, empty matrix of `row` rows and `col` columns. /// `data` contains no element. pub fn new_empty(row: usize, col: usize) -> Matrix { unimplemented!(); } /// Returns a shared reference to `data` pub fn data(&self) -> &Vec { unimplemented!(); } /// Returns a mutable reference to `data` pub fn mut_data(&mut self) -> &mut Vec { unimplemented!(); } /// Returns the number of rows and columns in the first and second /// elements of the tuple, respectively. pub fn size(&self) -> (usize, usize) { unimplemented!(); } } impl + Copy> ops::Add for &'a Matrix { type Output = Matrix; /// Returns the sum of `self` and `rhs`. If `self.row != rhs.row || self.col != rhs.col`, panic. fn add(self, rhs: Self) -> Self::Output { unimplemented!(); } } impl + Copy> ops::Add> for &'a Matrix { type Output = Matrix; /// Returns the sum of `self` and `rhs`. If `self.row != rhs.row || self.col != rhs.col`, panic. fn add(self, rhs: Matrix) -> Self::Output { unimplemented!(); } } impl + Copy> ops::Add for Matrix { type Output = Self; /// Returns the sum of `self` and `rhs`. If `self.row != rhs.row || self.col != rhs.col`, panic. fn add(self, rhs: Self) -> Self::Output { unimplemented!(); } } impl + Copy> ops::Add for Matrix { type Output = Self; /// Returns the sum of `self` and `rhs`. If `self.row != rhs.row || self.col != rhs.col`, panic. fn add(self, rhs: &Self) -> Self::Output { unimplemented!(); } } impl + Copy> ops::Sub for &'a Matrix { type Output = Matrix; /// Returns the subtraction of `rhs` from `self`. If `self.row != rhs.row || self.col != rhs.col`, panic. fn sub(self, rhs: Self) -> Self::Output { unimplemented!(); } } impl + Copy> ops::Sub> for &'a Matrix { type Output = Matrix; /// Returns the subtraction of `rhs` from `self`. If `self.row != rhs.row || self.col != rhs.col`, panic. fn sub(self, rhs: Matrix) -> Self::Output { unimplemented!(); } } impl + Copy> ops::Sub for Matrix { type Output = Self; /// Returns the subtraction of `rhs` from `self`. If `self.row != rhs.row || self.col != rhs.col`, panic. fn sub(self, rhs: Self) -> Self::Output { unimplemented!(); } } impl + Copy> ops::Sub for Matrix { type Output = Self; /// Returns the subtraction of `rhs` from `self`. If `self.row != rhs.row || self.col != rhs.col`, panic. fn sub(self, rhs: &Self) -> Self::Output { unimplemented!(); } } impl + ops::Mul + Copy> ops::Mul for &'a Matrix { type Output = Matrix; /// Returns the multiplication of `self` by `rhs`. If `self.col != rhs.row`, panic. fn mul(self, rhs: Self) -> Self::Output { unimplemented!(); } } impl + ops::Mul + Copy> ops::Mul> for &'a Matrix { type Output = Matrix; /// Returns the multiplication of `self` by `rhs`. If `self.col != rhs.row`, panic. fn mul(self, rhs: Matrix) -> Self::Output { unimplemented!(); } } impl + ops::Mul + Copy> ops::Mul for Matrix { type Output = Self; /// Returns the multiplication of `self` by `rhs`. If `self.col != rhs.row`, panic. fn mul(self, rhs: Self) -> Self::Output { unimplemented!(); } } impl + ops::Mul + Copy> ops::Mul for Matrix { type Output = Self; /// Returns the multiplication of `self` by `rhs`. If `self.col != rhs.row`, panic. fn mul(self, rhs: &Self) -> Self::Output { unimplemented!(); } } impl fmt::Display for Matrix { /// Formats the matrix as follows: /// * Writes each row on a separate line. No empty lines before or after any row. /// * On each row, writes each element followed by a single space, except no space following the last element of the row. /// Outputs using `write!(f, ...)`. fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { unimplemented!(); } } 

the following functions are given. implement them (may not need all functions). use std::{ops, fmt}; #[derive(PartialEq, Debug)] pub struct Matrix { /// Stores elements

in [row-major order](https://en.wikipedia.org/wiki/Row-major_order) data: Vec, /// Number of rows row: usize, ///

Number of columns col: usize, } impl Matrix { /// Creates a

new matrix of `row` rows and `col` columns, and initializes /// the

matrix with the elements in `values` in row-major order. pub fn new(row:

' You will define a "Matrix" type , overload the and * operators, and implement the - , Display trait on it by providing the following API: use std: fops, fmt); Debug)] #[derive ( PartialEq, pub struct Matrix Matrix Matrix Matrix { unimplemented! /// Returns a shared reference to data pub fn data (&self) -> &vec { unimplemented! /I/ Returns a mutable reference to data pub fn mut_data (&mut self) -> &mut Vec

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!