Giter VIP home page Giter VIP logo

java_ds_lab3_matrixmultiplication's Introduction

Java_DS_lab3_MatrixMultiplication

Lab 3 Matrix Multiplication Assignment 3 - Timing Matrix Multiplication Parts A is required. Part B is optional and is worth four points extra credit (but must be submitted in addition to, and along with, Part A). Make sure you have read and understood

both modules A and B this week, and module 2R - Lab Homework Requirements before submitting this assignment. Hand in only one program, please.

Part A (required) - A Simple Array Implementation for Large Matrices We already know how to allocate and work with 2-D arrays (matrices) from our CS 1B (CIS 27B) class. For example, here we allocate two double matrices:

  // non-sparse matrices
  double[][] mat, matAns;

  mat = new double[MAT_SIZE][MAT_SIZE];
  matAns = new double[MAT_SIZE][MAT_SIZE];

Look up matrix multiplication on the web or in a math book. It is a very simple and short formula, but it's good for you to find on your own. Create a static method in your main class that takes two input matrices, and the third a return (reference) product matrix:

public static void matMult( double[][] matA, double[][] matB, double[][] matC) To keep things simple, we'll assume all matrices are square, but we should check that the first rows of each matrix are the same size. If they are, we'll assume all is well (and let Java throw exceptions if the client passed bad matrices). After reading the definition of matrix multiplication, but before implementing it, determine, using the tools you have learned, the time complexity of this operation relative to M. You should be able to get both a tight O() upper bound as well as a ฮ˜() estimate for multiplying two MxM matrices together. Put this into writing to be handed in, along with your reasoning at the bottom of your assignment. Next, write the function for matMult(). Also, for comparison, write a display method for these dynamic matrices like you did for sparse matrices last week: one that shows a square sub-matrix of size = size anchored at position (start, start):

public static void matShow(double[][] matA, int start, int size This week we're making it a static function, so it must take the matrix as a parameter.

Now that we have our tools, we can time matrix multiplication (and examine small portions of the answers). Our game will be to generate a semi-sparse matrix (between 1% and 25% of the size of the matrix, non-zero) and then "square" the matrix (multiply it by itself) using matrix multiplication. We'll show a small 10x10 square sub-portion of the matrix, and then that same portion of the squared matrix.

java_ds_lab3_matrixmultiplication's People

Contributors

mikey084 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.