Tutorial: Matrix Structure

Tutorial: Using Matrix Structure

This tutorial explains how to use a Matrix structure for solving linear equations.

For the assignment, you must use the given Matrix structure and follow instructions for saving and modifying the data.

Preparation

Download

  1. Download data files:

  1. Download tutorial source and header files:

Create Data Folder (상대경로 방법)

Create a data folder in the workspace name the folder as NP_Data

  • ..\repos\NP\NP_Data

For each assignment, create the assignment folder and save the dataset.

Example: Assignment999

  • \NP\NP_Data\Assignment999

For this tutorial, unzip the downloaded data files and copy them under the data folder Assignment999

image

Create a folder in C:\ Drive and name the folder as NP_Data

  • C:\NP_Data

For each assignment, create the assignment folder and save the dataset.

Example: Assignment999

  • C:\NP_Data\Assignment999

For this tutorial, unzip the downloaded data files and copy them under the data folder Assignment999

NP_Matrix_Data_Example_img

Create Project

Create a new empty project in Visual Studio Community. Name the project as TU_MatrixTemplate

  • e.g ) C:\Users\yourID\source\repos\NP\tutorial\TU_MatrixTemplate

Create a new C/C++ source file for main()

  • Name the source file as TU_matrixTemplate.cpp

  • Use the downloaded source code : TU_matrixTemplate_student.cpp

Save the downloaded library header files in your \include\ folder

Then, you need to change in myMatrix.cpp as #include "myMatrix.h"

Create and Modify Dataset

For each assignment, create the assignment folder and save the dataset.

  • Example: Assignment000

    • \NP\NP_Data\Assignment000

Use the text file and file name as instructed in each assignment.

You must use the same name for the text files as instructed. Otherwise, it will not be graded

Example:

Make Text File

file_explorer_img

How to modify in the data file

  • Change Row : Enter

  • Change Column: Tap

Example :

Type:

  • 1 tab 3 tab -2 tab 4 enter .... 3 tab -1 tab 6 tab 2 ctrl+s (저장)

matrix_text_file_example

For Vector, type:

  • -11 enter 6 enter -9 enter 15 ctrl+s (저장)

vector_text_file_example

Using Matrix Structure Library

Matrix structure library

Provided library: myMatrix.h

Example Code

What to change for Assignment

  1. Initially, change the assignment number for #define ASGN

    • DO NOT modify other code lines

  1. Read data text files. You must use the given file names.

  2. Then, apply your numerical programming algorithm.

  1. Prints vector or matrix results. You have to give a brief description for each print.

  1. Free memory allocated to a matrix.

    • Even if you omit the free process, the code will work. However, it can cause memory leaks.


Assignment

Declare and define the following functions in myMatrix.h and myMatrix.cpp


Last updated

Was this helpful?