I am trying to read two matrices from individual .txt file, and later trying to multiply them. But I am unable to succeed.
Here is the code.
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
// Here starts the main
int main()
{ // The two input values
FILE *inputFile1;
FILE *inputFile2;
[Code] .....
I am able to get only the first values as the output. The first matrix is 5x3, and the second one is a 3x3 matrix.
Matrix 1
1 2 3
4 5 6
7 8 9
10 11 12
Matrix 2
1 2 3
4 5 6
7 8 9
The output which I am getting is
Enter File name of matrix #1 - with extention - : matrix1.txt
Enter File name of matrix #2 - with extention - : matrix2.txt
Rows1 = 1 Cols1 = 2
Rows2 = 1
Cols2 = 2Cant multiply those two matrices
I just want to know the code of the program: Write code to accept matrix as aurgument and display its multiplication matrix which return its multiplication matrix.
I am writing a brute force implementation of matrix multiplication:
Header file:
vector<vector<int> > matrix_multiplication(vector <vector<int> >& a, vector <vector<int> >& B)/>/>/>;
Source file:
vector<vector<int> > matrix_multiplication(vector <vector<int> >& a, vector <vector<int> >& B)/>/>/>{ int n = a.size(); vector< vector <int> > c (n , vector<int> (n)); for (int i =0 ; i<n ; i++){ for (int j =0 ; j < n ; j++){ for (int k ; k < n ; k++){ c[i][j] = a[i][k] + b[k][j];
[Code] ....
I keep on getting occasional seg faults />/>. I can't see why.
I just started Linear Algebra for my programming degree and to full understand everything I want to put it into code and make my own "matrix calculator." I have all the theory but I am having issues keeping the matrix variable and moving it around the class' functions to create it and output it. Once I know I have it saved I think I can get the addition/multiplication to work. Here is the code I have so far:
#include <string> #include <iostream> using namespace std; class matrix {
I am actually working on IEEE Arithmetic especially the IEEE 754 specification where the IEEE double only have 53 bits of precision. I am working on Z/nZ matrix multiplication that works on 53 bits specs. How to write a matrix multiplication algorithm that works well on 53 bits IEEE precision standard.
I've been trying to get my matrix multiplication program to run a few different ways. My assignments wants me to run it statically using chunks, but we're not supposed to use OpenMPs scheduler. So I'm not sure how that's possible. And secondly, we have to run it dynamically using locks/unlocks.
I wrote program for Sequential matrix multiplication .But after execution for any input value( ex. 100,150,400) it shows the execution time is 0.000 msec.
#include <stdio.h> #include <math.h> #include <sys/time.h> void print_results(char *prompt, int N, float *a); int main(int argc, char *argv[])
Basically I am to create a program that will read two saved text files; one is [2x4] ~ (matrixA.txt) and another is [4x2] ~ (matrixB.txt). The program is supposed to read both text files, multiply them, and generate an output that will be saved as ~ (matrixC.txt).
C:UsersLeDerpHW1.c: In function `main': HW1.c:27: parse error before `int' //Line 28 C:UsersLeDerpHW1.c: At top level: HW1.c:34: warning: parameter names (without types) in function declaration //35 HW1.c:34: warning: data definition has no type or storage class //35 HW1.c:35: parse error before `for' //37
but if the matrix is compressed_matrix type, there's something with it. the error log as below:
Check failed in file boost_1_48_0/boost/numeric/ublas/detail/matrix_assign.hpp at line 1078: detail::expression_type_check (m, cm) terminate called after throwing an instance of 'boost::numeric::ublas::external_logic' what(): external logic Aborted
I am writing a program to hide files behind other files using Alternate Data Streams in Windows NTFS file systems.
The program is as follows:
Code:
#include <stdio.h> #include <stdlib.h> int main(void){ char hostfile[75], hiddenfile[75], hiddenFileName[15] ; printf("Enter the name(with extension) and path of the file whose behind you want to hide another file: "); scanf("%75s", hostfile);
[Code]...
The complier is showing error as "Extra Perimeter in call to system" but I am not getting where?
I am writing a piece of code that requires me to display the last 1000 lines from a multiple text files (log files). FYI, I am running on Linux and using g++.
I have a log file from which - if it contains more than 1000 lines, I need to display the last 1000 lines. However, the log file could get rotated. So, in case where the current log file contains less than 1000 lines, I have to go to older log file and display the remaining. For e.g., if log got rotated and new log file contains 20 lines, I have to display the 980 lines from old log file + 20 from current log files.
What is the best way to do this? Even an outline algorithm will work.
First index of the second line tells the number of non-zero entries of the first row and second index tell the column number where the non zero entry is placed
I want to set an integer to zero when it easy equal to another integer, but it seems that the program for some reason won't set the integer to zero. Here is the example of that code:
#include <iostream> using namespace std; int main () { int n = 2; int r = 2; if(n==r) n++; r*0; cout << " n is " << n << endl; cout << " r is " << r << endl; }
What am I doing wrong, it should say that "n is 3" and "r is 0".
I want to declare a 2D 4*4 array, and fills the array with the multiplication table of an integer x from the user, for example: x*1,x*2,x*3, ....., x*16 and how to pass that array to a function to print the array and to another function that swaps a column with another column chosen by the user.