In this first part of the lab, you’re asked to create a Windows-based console application in C++ using Microsoft Visual Studio. Your application needs to test drive a powerful matrix template library called Eigen, it needs to output some stuff to the screen, and it needs to be shareable with others so it can run on any Windows computer.

Step 1: Find and get familiar with Microsoft Visual Studio IDE

This lab assumes you’ve already got Microsoft Visual Studio installed on your computer or in your lab.

If that’s right then go find it and get familiar with the Integrated Development Environment (IDE).

Here’s a decent first tour of the Integrated Development Environment for Visual Studio 2015 »

(If you don’t already have Visual Studio installed then this might help »)

Step 2: Create your first application

Next, follow these steps » to create, debug, test, and release your first “Hello, world” style Win32 console application. When you do this, be sure that you specify wanting to create a console application.

Be sure to give it an appropriate name, e.g. YourName-Lab1Part1

When doing this myself I found the context and tips provided here to be useful:

Step 3: Include the Eigen template library in your project

Next we’re going to extend your application beyond the basic “Hello, world” functionality to do some simple stuff with matrices. You’re going to learn how important this is for geomatics networks.

In order to do this, you’re going to need to include in your project a pretty powerful C++ template library called Eigen that lends a whole bunch of linear algebra functionality your code. It makes easy (and numerically reliable) work of using matrices, vectors, numerical solvers, and related algorithms in your applications.

First, you need to download it »

Then, you need to install it and set it up in Visual Studio. You might find this video » helpful.

Step 4: Make your application do some great stuff

Once you’ve got a console application up and running (Step 2 above) and you’ve successfully included the Eigen library (Step 3 above), I want you to have your program do the following:

1. Output a short welcome message in this format:

Hi. My name is [your first name]. Welcome to my program!

2. Declare a 2 x 2 matrix

When working with the Eigen library, you might find the following useful: Quick reference for Eigen » I also found it quite quick to just Google what I needed to do.

3. Assign values to your matrix one element at a time such that it has elements with values given by the following:

    \begin{equation*} $\mathbf{M} =\begin{bmatrix} m_{1,1} & m_{1,2} \\ m_{2,1} & m_{2,2} \end{bmatrix} \end{equation*}

where

    \begin{equation*} \begin{split} m_{1,1} = 3 \\ m_{1,2} = 2.5 \\ m_{2,1} = -1 \\ m_{2,2} = m_{2,1} + m_{1,2} \end{split} \end{equation*}

4. Output your matrix to the screen after the following message:

The first matrix is as follows:

5. Resize the original matrix to a 3 x 3 matrix and output its contents after the following message:

After resizing, my matrix is as follows:

6. Assign the following new values to the resized matrix, all at once (not one element at a time):

    \begin{equation*} $\mathbf{M} =\begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{bmatrix} \end{equation*}

7. Output the matrix to the screen again after the following message:

With new elements, my matrix is as follows:

8. Output the sum of all elements of the matrix after the following message:

The sum of all its elements is:

9. Output the transpose of the matrix (without altering the contents of the matrix), after the following message:

And the matrix has the following transpose:

Step 5: Properly document and organize your code

Make sure to properly document and organize your code. Check out these guidelines » if you’re not familiar. And be sure to include the course name and number as well as your name and number in the opening comments.

Step 6: Create an executable that can be run on any Windows computer

This video » contains the basic steps for doing this. The executable you create should be ready to run on any computer.

Step 7: Submit your application and code

When you’ve completely finished your application you need to prepare it for submission.

To do this, add the following to your report:

  1. The code (the .cpp file) as an appendix to the report you submit for this lab
  2. A screenshot of the output you get when running the application yourself – include this in the body of your report for this part

Step 8: Move to Part 2 of this lab when you’re ready

Once you’ve finished this first application you can proceed to Part 2 in the next lesson using the buttons below.

In order to do this you will need to be signed in (at the top right corner of the page) and then press “Unlock the next lesson”.