Posts

Showing posts from April, 2019

Matrix Multiplication (Square of a Matrix) using Threads in JAVA

Image
This program will take a text file as a command line argument. The text file will have the first row indicating the total number of rows and columns which will be equal as this program is programmed to read a square matrix from a file and calculate its square using threads.

Content of the text file to be given as an argument

14
0 1 0 7 5 3 1 0 1 0 7 5 3 1
2 0 0 3 2 2 2 3 0 2 9 0 2 3
2 1 1 2 2 2 4 0 0 2 4 3 3 5
3 0 2 9 0 2 6 1 2 3 4 5 6 7
2 0 0 3 2 2 2 3 0 2 9 0 2 3
2 1 1 2 2 2 4 0 0 2 4 3 3 5
3 0 2 9 0 2 6 1 2 3 4 5 6 7
0 1 0 7 5 3 1 2 0 0 3 2 2 2
3 0 2 9 0 2 3 2 1 1 2 2 2 4
0 0 2 4 3 3 5 3 0 2 9 0 2 6
1 2 3 4 5 6 7 0 1 0 7 5 3 1
2 0 0 3 2 2 2 3 0 2 9 0 2 3
2 1 1 2 2 2 4 0 0 2 4 3 3 5
3 0 2 9 0 2 6 1 2 3 4 5 6 7

The first row indicates the total number of rows and columns, in this case, rows=cloumns=14.
And the next rows will be the actual matrix which we want to multiply with itself. The program will calculate the square of the matrix written in your file.

import java.util.*;
import java.io.*; 

class MMT…

Simpletron Complete Program in C [Solved]

Image
The Simpletron runs programs written in the only language it directly understands that is, Simpletron Machine Language, or SML for short. All information in the Simpletron is handled in terms of words. A word is a signed four-digit decimal number such as +1009 +1010 +2009 +3110 and so on. The Simpletron is equipped with a 100- word memory, and these words are referenced by their location numbers 00, 01, …, 99. Before running an SML program, we must load or place the program into memory or the array of the program considered it as the RAM of the computer. The first instruction of every SML program is always placed in location 00. 

Each instruction written in SML occupies one word of the Simpletron’s memory, so instructions are four-digit decimal numbers. Each location in the Simpletron’s memory may contain either an instruction, a data value used by a program or an unused (and hence undefined) area of memory.

For more details you can read the section 7.27 Building your own computer of De…