Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Details here: http://web.eecs.utk.edu/~plank/plank/classes/cs140/Labs/Lab5/ here

ID: 3551789 • Letter: D

Question

Details here: http://web.eecs.utk.edu/~plank/plank/classes/cs140/Labs/Lab5/


here is bitmatrix.cpp - implementing bitmatrix.h


#include <fstream>

#include <sstream>

#include <cstdlib>

#include <cstdio>

#include <algorithm>

#include "bitmatrix.h"


Bitmatrix::Bitmatrix(int rows, int cols)

{

for (int i=0; i < rows; i++) {

for (int j=0; j < cols; j++) {

cout << "0 "; } }

if (!(rows <= 0 && cols <= 0)) {

cout << "0 ";

cerr << " " << endl; exit(1); }

}


int Bitmatrix::Rows()

{


return M.size();

}


int Bitmatrix::Cols()

{

return string.size();

}


void Bitmatrix::Set(int row, int col, char val)

{


}


char Bitmatrix::Val(int row, int col)

{


return -1;

}


void Bitmatrix::Print(int w)

{

int i, j;


for (i = 0; i < M.size(); i++) {

if (w > 0 && i != 0 && i%w == 0) printf(" ");

if (w <= 0) {

cout << M[i] << endl;

} else {

for (j = 0; j < M[i].size(); j++) {

if (j % w == 0 && j != 0) printf(" ");

printf("%c", M[i][j]);

}

cout << endl;

}

  }

}


void Bitmatrix::Write(string fn)

{

}


void Bitmatrix::Swap_Rows(int r1, int r2)

{

}


void Bitmatrix::R1_Plus_Equals_R2(int r1, int r2)

{

}


Bitmatrix::Bitmatrix(string fn)

{

ifstream f;

int i, j;

string s, row;


f.open(fn.c_str());

if (f.fail()) { perror(fn.c_str()); M.resize(1); M[0].resize(1), M[0][0] = '0'; return; }


while (getline(f, s)) {

row.clear();

for (i = 0; i < s.size(); i++) {

if (s[i] == '0' || s[i] == '1') {

row.push_back(s[i]);

} else if (s[i] != ' ') {

fprintf(stderr, "Bad matrix file %s ", fn.c_str());

M.resize(1); M[0].resize(1), M[0][0] = '0';

f.close();

return;

}

}

if (s.size() > 0 && M.size() > 0 && row.size() != M[0].size()) {

fprintf(stderr, "Bad matrix file %s ", fn.c_str());

M.resize(1); M[0].resize(1), M[0][0] = '0';

f.close();

return;

}

if (s.size() > 0) M.push_back(row);

}

f.close();

}


void Bitmatrix::PGM(string fn, int pixels, int border)

{

}


Bitmatrix *Bitmatrix::Copy()

{

return NULL;


}

BM_Hash::BM_Hash(int size)

{

}


void BM_Hash::Store(string &key, Bitmatrix *bm)

{

}


Bitmatrix *BM_Hash::Recall(string &key)

{

return NULL;

}


HTVec BM_Hash::All()

{

HTVec rv;

return rv;

}



Bitmatrix *Sum(Bitmatrix *m1, Bitmatrix *m2)

{



return NULL;

}


Bitmatrix *Product(Bitmatrix *m1, Bitmatrix *m2)

{

return NULL;

}


Bitmatrix *Sub_Matrix(Bitmatrix *m, vector <int> &rows)

{

return NULL;

}


Bitmatrix *Inverse(Bitmatrix *m)

{

return NULL;


}

Explanation / Answer

1 // BitMatrix.cpp: implementation of the CBitMatrix class. 2 // 3 ////////////////////////////////////////////////////////////////////// 4 5 //#include "stdafx.h" 6 //#include "TXTCompare.h" 7 #include "BitMatrix.h" 8 9 ////////////////////////////////////////////////////////////////////// 10 // Construction/Destruction 11 ////////////////////////////////////////////////////////////////////// 12 13 /* 14 inline CBitMatrix::CBitMatrix(unsigned int rows, unsigned int cols) 15 : rows_ (rows), 16 cols_ (cols), 17 data_ (new int[rows * cols]) 18 { 19 if (rows == 0 || cols == 0) 20 throw; //BadIndex("Matrix constructor has 0 size"); 21 } 22 23 inline CBitMatrix::~CBitMatrix() 24 { 25 delete[] data_; 26 } 27 28 inline int& CBitMatrix::operator() (unsigned int row, unsigned int col) 29 { 30 if (row >= rows_ || col >= cols_) 31 throw; //BadIndex("Matrix subscript out of bounds"); 32 return data_[cols_*row + col]; 33 } 34 35 inline int CBitMatrix::operator() (unsigned int row, unsigned int col) const 36 { 37 if (row >= rows_ || col >= cols_) 38 throw; //BadIndex("const Matrix subscript out of bounds"); 39 return data_[cols_*row + col]; 40 } 41 */

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote