Click here to Skip to main content
15,899,313 members
Everything / Matrix

Matrix

Matrix

Great Reads

by Arthur V. Ratz
Optimizing the performance of the large-sized matrices QR factorization and eigendecomposition, using Schwarz-Rutishauser algorithm
by Arthur V. Ratz
Compute the Levenshtein distance of literal strings effectively by using the Wagner-Fischer (two matrix rows-based) algorithm.
by Virendra Kulkarni
Steps to implement the “Fit picture to fill the shape” option in PowerPoint like applications using GDI+
by Mahsa Hassankashi
This article also has a practical example for the neural network. You read here what exactly happens in the human brain, while you review the artificial neuron network.

Latest Articles

by Arthur V. Ratz
Compute the Levenshtein distance of literal strings effectively by using the Wagner-Fischer (two matrix rows-based) algorithm.
by Arthur V. Ratz
Optimizing the performance of the large-sized matrices QR factorization and eigendecomposition, using Schwarz-Rutishauser algorithm
by Mahsa Hassankashi
This article also has a practical example for the neural network. You read here what exactly happens in the human brain, while you review the artificial neuron network.
by Peter Occil
Describes projection and view transforms commonly used in 3D graphics, such as perspective and orthographic transforms

All Articles

Sort by Updated

Matrix 

2 Oct 2023 by sahil ajmeri 2022
I have STL file where I want to apply 4x4 matrix. The matrix I want to apply is: [[2.7282, 0, 0, 0], [0, 4.0014, 0, 0], [0, 0, 1, 0], [0,�0,�0,�1]] Here is my STL file: https://we.tl/t-v6SHprAeUZ[^] I have used Python code to apply matrix...
11 Oct 2022 by Animesh jain 2022
I was coding a matrix inversion algorithm It works with almost all of the matrixes except one with zeros in the diagonal entries Like: 8 9 0 0 0 8 0 9 10 and similar if Argument_Matrix[i][i] != 0: Argument_Matrix[i] /=...
11 Oct 2022 by Peter_in_2780
Assuming the input matrix is non-singular, there are many well-proven algorithms for matrix inversion. To overcome your immediate problem of zeros on the main diagonal, you should read up on pivoting in the context of matrix manipulation. While...
25 Sep 2022 by NoName900
i'm trying to code a Minesweeping game in java and i don't know how to create the board. What I have tried: this is my code: import javax.swing.*; import java.awt.*; public class Board extends JFrame { static final int Col=9; ...
16 Sep 2022 by Arthur V. Ratz
Compute the Levenshtein distance of literal strings effectively by using the Wagner-Fischer (two matrix rows-based) algorithm.
28 Jun 2022 by UPPALAPATI DATTA (RA2111030010270)
#include void add(){ int p,q,x,y,i,j; int a[100][100],b[100][100],c[100][100]; for(j=0;j
28 Jun 2022 by Patrice T
First of all, you can't add 2 matrices of different size. I would try this change: #include // This make the matrices and sizes global. int p,q,x,y; int a[100][100],b[100][100],c[100][100]; void add(){ int p,q,x,y,i,j; int...
28 Jun 2022 by Member 12006214
Refer below Code #include int main() { int r, c, i, j, a[100][100], b[100][100], sum[100][100]; printf("Enter the number of rows (between 1 and 100): "); scanf("%d", &r); printf("Enter the number of columns (between 1 and...
15 Jun 2022 by CPallini
Try the following code n=3 adjacency_matrix =[ [2, 3, 0] , [0, 0, 1] , [1, 5, 0] ] li_r = [] li_c = [] for i in range(n): for j in range(n): if adjacency_matrix[i][j]!=0: li_r.append(i) li_c.append(j) print(li_r) print(li_c) ...
15 Jun 2022 by niksirat2030
Hi, I create matrix "adjacency_matrix" with following code: n = int(input()) # Initialize matrix adjacency_matrix = [] # For user input for i in range(n): a =[] for j in range(n): a.append(int(input())) adjacency_matrix.append(a) I...
15 Jun 2022 by merano99
Starting here with a user menu does not make much sense. On the contrary, I would leave it out first and the required functions first to read in the matrices and write the functions possible with the matrices. In order to complete the tasks,...
14 Jun 2022 by Richard MacCutchan
See Matrices[^] for the algorithms that you need to implement.
14 Jun 2022 by OriginalGriff
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for...
14 Jun 2022 by CPallini
You did practically nothing. There are basically three tasks: Matrix computations, that is addition, subtraction, multiplication of two matrices. Matrix input from file and output to file. Interpret the command line and execute it. For...
14 Jun 2022 by RickZeeland
See example here: Matrix calculator in C - Code Review Stack Exchange[^] You can not copy and paste this code, you will have to adapt it according to the instructions you got. Good luck!
25 Apr 2022 by abc174
So I have a table which holds words and their counts. I want to create a histogram with it but I'm not pretty sure where to start. wordCount() func returns table's row count. What I have tried: public class TestHistogram { public static...
26 Mar 2022 by Atharav Jadhav
I have tried giving input for a 2X2 matrix. 0 1 0 x x 1 y x But the output still is "Matrix not allowed" according to my code, whereas for this input it should just run well. Please let me know where I am going wrong. What I have...
13 Mar 2022 by loop063
I have a 15x15 matrix with strings of "0"s and "1"s. I need to find the number of columns that have only one "0". Note that the variables in the matrix are strings, not numerics What I have tried: colSums(m1=="1", na.rm=TRUE)
10 Mar 2022 by Luc Pattyn
Aha, That is a special case of a more general optimisation job I've spent many years on; I ended up with a very nice approach that is the opposite of brute force, and provides all solutions in one go. Applied on your matrix situation, I'd like...
10 Mar 2022 by Member 15561967
I have a 2D array with ones and zeros, for example: 1 0 0 0 0 1 0 0 1 0 1 0 1 0 0 1 I need to find if there is a group of columns (or a single column) that have a row sum equal 1. For the above array the answer is YES because: 1 + 0 = 1 0 + 1...
9 Mar 2022 by JamesDorr
Can you help me with this in Matlab I have this matrix A= 10 20 30 40 60 70 80 90 100 B= 1 1 1 1 1 1 how can i add matrix B into the end of matrix A to look like this C= 10 20 30 40 60 70 80 90 100 1 1 1 What I have...
9 Mar 2022 by Arthur V. Ratz
Here's the solution: And, this is done in MatLab just like in Python and NumPy, such as: For rows: A = ones(1,4); B = zeros(1,4); C = [A B] D = [A;B] For columns: A = ones(2,3) B = zeros(2,2) C = [A B] I basically refer to Creating,...
3 Jan 2022 by Arthur V. Ratz
Optimizing the performance of the large-sized matrices QR factorization and eigendecomposition, using Schwarz-Rutishauser algorithm
15 Dec 2021 by Enes Şahin 2021
I have two files with nrrd extension. I am reading them by using nrrd module and saving to 3D array. Now I have two 3D arrays and I want to calculate fastly hausdorff distance between them in pixel. And I have to use python. Here is the small...
15 Dec 2021 by Richard MacCutchan
hausdorff distance python - Google Search[^]
27 Oct 2021 by M Sanei
I want to create a 2D array data with 100 row and 100 column in which every cell would be a float number between 0 and 10 randomly generated, store row by row. After that implement selection and range queries on it. What I have tried: I have...
27 Oct 2021 by Rick York
I use this function to generate random values : // obtain a random value scaled to be within limits template inline T GetRandomValue( T minval, T maxval ) { return ( rand() * ( maxval - minval ) / (T) RAND_MAX ) + minval; }...
27 Oct 2021 by Richard MacCutchan
You can declare the array thus: float floatArray[100][100]; The array is indexed by expressions of the form floatArray[row][col], where row and col are integer offsets between 0 and 99. You can use srand/rand to generate random numbers.
20 Oct 2021 by Matt Weber_1
I'm developing a Connect 4 Python program. When I'm attempting to play the game and trying to "stack" the tokens, instead of doing so they just replace each other after each turn if the other/same user picks the same column. For example, this...
20 Oct 2021 by OriginalGriff
When you "drop" a token, you need to scan the column and find the first "used slot". The simplest way to do that is to expand the storage area by one in all directions (so that the board matrix for a 3 x 3 board is 5 x 5) and fill the "edges"...
20 Mar 2021 by MMS98
Hi, I have this program which prompts the user for a matrix’ dimensions then for its elements. I have done input validation correctly, but my problems is with asking to input at least the correct number of inputs needed to get the matrix for...
20 Mar 2021 by Patrice T
Quote: currently, I'm unable to get an output at all. Your code is really weird, difficult to see what you try to do. I would expect only 2 loops there: for i in range(rowsNumber): for j in range(columnsNumber): for x in...
8 Feb 2021 by Captian Ahab
I just came over from Stack Overflow after getting question banned, so I have no idea how you guys will like me, but here goes. I have a 16x16 matrix, and I'm trying to move the columns to the right. What I have tried: Here's how I have it...
8 Feb 2021 by RickZeeland
See answer here: Python and matrix, move columns & rows - Stack Overflow[^]
8 Dec 2020 by gsile
I have been trying to link my "person" class values with "workers" class in the "Read" method. When I write Console.WriteLine(person.GetName()); it gives me all the values perfectly, but if I write Console.WriteLine(workers.Get(i).GetName());...
8 Dec 2020 by Afzaal Ahmad Zeeshan
That is why normally it is recommended to not have a long chain of method calls, if any single one of them fails you get a null reference exception. I would suggest rewriting that log line as: var worker = workers.Get(i); if(worker != null) { ...
25 Nov 2020 by Richard MacCutchan
Sorry, this site is not here to do your homework. If you really cannot do this the you need to discuss your problem with your teacher.
4 Nov 2020 by raddevus
[0.91, 0.81, 0.72, 0.74, 0.33, 0.85] [0.91, 0.81, 0.72, 0.74, 0.33, 0.85] [0.91, 0.81, 0.72, 0.74, 0.33, 0.85] [0.91, 0.81, 0.72, 0.74, 0.33, 0.85] [0.91, 0.81, 0.72, 0.74, 0.33, 0.85] now iterate through each row and each column for row = 0...
4 Nov 2020 by justilian
New programmer here, I got a task to make a program that picks and displays number of numbers greater than 0.8 in a random matrix 5x6 with 2 for loops and would appreciate help if someone knows how to make it. Thanks in advance. this is how...
4 Nov 2020 by Southmountain
this article has the logic in you need 13 void showmat(Mat* A){ 14 if(A->row>0&&A->col>0){ 15 int k=0; 16 printf("["); 17 for(int i=1;irow;i++){ 18 for (int j=1;jcol;j++){ 19 if(jcol){ 20 ...
2 Nov 2020 by Patrice T
You show no attempt to solve the problem yourself, you have no question, your main effort is pasting the requirement, you just want us to do your HomeWork. HomeWork problems are simplified versions of the kind of problems you will have to solve...
2 Nov 2020 by OriginalGriff
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us...
27 Aug 2020 by Member 14924606
I'm looking for an approach to this problem where you have to fill a NxM (N!=M) piece matrix with L-shaped three piece tiles. More accurate to say it s that every element of the matrix is a square and with an L-shaped i cover 3 elements . ...
27 Aug 2020 by Rick York
I would write numbers in the squares to indicate which shape it is part of with zero being empty. The first shape will be number one, the second will be two, and so on. The part I am uncertain of how do you distinguish between attempts? One...
27 Aug 2020 by Sandeep Mewara
I see you have posted this same query in atleast three forums. By now you know its a broad topic and since you are asking for some direction to start in comments here (and at SO), take a cue from this: combinatorics - How many ways can you tile...
15 Apr 2020 by RickZeeland
Here is a similar question, the trick is to use a button and add the values to the array after the button is clicked: Get input from a textbox to an array in C#[^]
15 Apr 2020 by bekim peci
So basically I have to ask the user to input the text in the textBox and then , add that input into the matrix, but the code i have written doesn't give me time to get the user input What I have tried: public void FillMatrix (string...
28 Mar 2020 by CPallini
A diagonal starting at (row,0) includes all items (row+k,k) where k=0,1,.., ROWS-row-1. In a similar way, a diagonal starting at (0,col) includes all items (k,col+k) where k=0, 1, .., COLS-col-1. The task is competed if you iterate on rows: row...
28 Mar 2020 by R0ber1t
I'm looking for a C++ way using vector to get all the diagonals of a (square) matrix, represented as a 2d vector. matrix = [ [1,2,3,4], [5,1,2,3], [9,5,1,2]] But I have trouble coming up with a way to generate all the diagonals....
14 Dec 2019 by Member 14689791
Saruss' Rule can be useful for faster & memory efficient computation of Determinant. because it is non recursive. You can get application on https://github.com/apanasara/Faster_nxn_Determinant
25 Jun 2019 by Stefan_Lang
It's a variant of the Traveling Salesman problem[^] (you have to visit all cells of the matrix) with an unusual cost function. The cost function can only be evaluated once you have a full path. Moreover a full path needs to visit all cells. You migth want to look up implementations of the...
25 Jun 2019 by Noble Badass
Minimum matrix You are given an integer matrix A of size N×M. You start on the left upper corner cell (with coordinates (1,1)). You can walk in four directions. You can not visit the same cell twice. You have to visit every cell of matrix A. When you stand on a cell, your maximum value is...
24 Jun 2019 by Patrice T
Quote: Program to find minimum matrix Yes it is what you have to do ! In this site, we help you to fix your program, but you need to have a program, we don't do your homework for you. The requirement is typical of challenges sites, so your challenge is to solve the problem, In your case you...
24 Jun 2019 by Maciej Los
Take a look here: Dijsktra's algorithm[^]
24 Jun 2019 by OriginalGriff
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you. So we need you to do the...
22 May 2019 by OriginalGriff
This is basic maths. targetRow - row is the horizontal distance from the target to the centre of your circle with radius radius, and targetColumn - col is the vertical distance. The radius by definition never shorter than the longest of the absolute values of those two, so it is always the...
22 May 2019 by Member 14422952
I have the dimensions of a matrix and a given cell with radius. So let's take a look at this example: https://i.imgur.com/51hTJpv.png[Matrix] The matrix has 5 rows and 6 columns. We are given the cell (2, 3) with radius 2. It has an impact, and it destroys all of the items in a certain radius...
26 Apr 2019 by Richard MacCutchan
You first need to split the string using the semi-colon as the separator,. That will give you a string of numbers for each row. Then split each substring using the comma as separator which will give the numbers for each column. You can then allocate the array for the matrix. You then need to...
26 Apr 2019 by merna adel
It is required to develop a program to do Matrix operations. The program use a defined string format to represent the matrix in the user input and output sections. For the following matrix: examplee : the user input the string representation of the Matrix : ex:[10 2.13 3;-5 0 4;16.5 1 8] In the...
26 Apr 2019 by Gerry Schmitz
How to split a string in C++ - Fluent C++[^]
3 Apr 2019 by Mahsa Hassankashi
This article also has a practical example for the neural network. You read here what exactly happens in the human brain, while you review the artificial neuron network.
17 Jan 2019 by Peter Occil
Describes projection and view transforms commonly used in 3D graphics, such as perspective and orthographic transforms
17 Nov 2018 by Optimistic76
I finally found a link i never noticed that answer to my question Eigen: Lazy Evaluation and Aliasing[^]
15 Nov 2018 by Richard MacCutchan
matrix multiplication c - Google Search[^]
15 Nov 2018 by Optimistic76
Hello, I'm trying to understand how mathematical libraries that use Expression Templates techniques ( like Eigen for exmaple ) handle Matrix Multiplication. What I have tried: In many examples I found there is always just the element-wise operation implemented: A = B*C + D is compiled as a...
14 Sep 2018 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action. Try it yourself, you may find it is...
22 Aug 2018 by Member 13958396
This is my first time doing matlab and I've never coded before. This was a compulsory Uni paper that I have had to take. Prior to this task I've managed to complete various other tasks but this is challenging me beyond what I've learned in the last three weeks. This is what ive got down so far...
22 Aug 2018 by Vincent Maverick Durano
READ: Programming Problems and Finding Solutions[^] PS: Adding those exclamation marks on the subject line suggests you are late with your homework, it's rude and no one is interested in that. If you want us to help you, then start doing something by yourself. Show us what you've tried and...
22 Aug 2018 by Member 13958388
SOMEONE PLEASE HELP ME SOLVE THIS?!?!?!?! SelectKRandomPointsPurposeSelectKRandomPoints generates a list of k randomly selected pixelsfrom an image. Input(s):It takes twoinputs in the following order: 1)A 3D image array from which to select points from 2)The number of points to randomly...
22 Aug 2018 by Patrice T
So, you show no attempt to solve the problem yourself, you have no question, you just want us to do your HomeWork. HomeWork problems are simplified versions of the kind of problems you will have to solve in real life, their purpose is learning and practicing. We do not do your HomeWork....
22 Aug 2018 by Patrice T
Quote: SOMEONE PLEASE HELP ME SOLVE THIS?!?!?!?! The help you want is us doing your homeWork. You show no attempt to solve the problem yourself, you have no question, you just want us to do your HomeWork. HomeWork problems are simplified versions of the kind of problems you will have to solve...
8 Aug 2018 by Member 13770264
Dictionary Matrices = new Dictionary a) { object[] ruleArray = new object[a.Count]; int num = 0; foreach (KeyValuePair
8 Aug 2018 by OriginalGriff
Quote: 'System.InvalidCastException' Helps a bit, but knowing which line would make our job easier... At a guess, it's this line: m[h,j] =(int)a[i]+(int)a[i+1] ; and it implies that a does not contain integers. So start by looking at what exactly Tab_Mat does return, then use the debugger to...
10 Jan 2018 by Member 13616707
can someone help me to finish this code to work whole in one code. # include ........... ..................... int main() { readMatrice(A,n,m); printMatrice(A,n,m); convertMatriceToVector(A,n,m,V); writeVector(V); sortVector(V); writeVector(V); convertVectorToMatrice(V,n,m,A); ...
10 Jan 2018 by CPallini
Start writing the Matrice and Vector classes (at least their skeletons), then start filling properly the methods. Take advantage, if you can, of the modern features of C++, in order to simplify your task.
10 Jan 2018 by Patrice T
Quote: can someone help me to finish this code to work whole in one code. Finish what? this code is barely as starting point. All you gave us a couple function names and not explanation. Your teacher is the only one that can help you with no explanation. We do not do your HomeWork. HomeWork is...
30 Nov 2017 by Lilyanaa
I'm trying to create a simple Matrix Multiplication program with MPI ,the idea of this code is split the first matrix (a) by row and the second matrix(b)by column and send these rows and columns to all processors ,the program must be (first matrix split by rows * second matrix split by columns)...
30 Nov 2017 by Kenneth Haugland
This seems wrong to me: for(i = 0; i
27 Nov 2017 by Lilyanaa
I find what I need from Stack Overflow and now I have a question,what is the benefit of this function static void transpose_matrix() { int i, j; for(i = 0; i
27 Nov 2017 by Kenneth Haugland
In the header, you ask about matrix multiplication, while in the question you ask about transposing a matrix. Transposing a matrix is just to switch the rows and columns: TransposeA[i][j]=A[j][i] Matrix multiplication is a bit more cumbersome as you need to make sure that the columns in the...
19 Nov 2017 by Amar Ćatović
#include int main() { printf("Enter M and N of matrix A: "); int m,n; int p,q; scanf("%i %i",&m,&n); printf("Enter matrix elements: "); int i,j,matA[101][101]; for (i=0; i
19 Nov 2017 by Patrice T
Quote: It rotates N x N matrix like it should, but there is problem with M x N matrix. You need to take into account that the shape of the matrix changes after transpose. There is a tool that allow you to see what your code is doing, its name is debugger. It is also a great learning tool...
18 Nov 2017 by OriginalGriff
Compiling does not mean your code is right! :laugh: Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English, rather than German for example - not that the email contained the message you wanted to send. So now...
26 Aug 2017 by suraty
Hello, For a java program, the input file is a matrix. Java program will do read the input file and then do some things. Each line of the file contains row number, column number, the weight of the edge between two nodes. such as: 1,1,0 1,2,-1 1,3,2 ... Self-loop is equal zero, and if there is no...
26 Aug 2017 by OriginalGriff
There is no such value that you can insert as a number: that is the nature of "infinite values". Instead, I'd write something that wasn't a number at all - a character like 'i' or even '∞' if your file is Unicode and specifically check for that when I read the file back while converting the...
30 Jul 2017 by Member 13336847
How can I add or subtract 2 Algebraic expressions in C which have 2 variables. I realize it could be done using matrix but that would leave many null spaces. Can anyone please write a program dynamically allocating the arrays. How can I do with sparse matrix (array representation) Example...
30 Jul 2017 by Ravi Bhavnani
You don't need to use a matrix. Simply use a collection of structures, each of which contains: coefficient power of x power of y and sum the coefficients of like power combinations. /ravi
30 Jul 2017 by Graeme_Grant
Sorry, we do not do your homework for you.
7 Jul 2017 by Member 13298704
I am not getting correct output What I have tried: void main() { int a[5][5],i,j,k,t; for(i=0;i>a[i][j]; } for(k=0;ka[k+1]) { t=a[k+1]; a[k+1]=a[k]; a[k]=t; } } for(k=0;k
7 Jul 2017 by Patrice T
First of all, indent your code properly, it helps reading. void main() { int a[5][5],i,j,k,t; for(i=0;i>a[i][j]; } // this loop is very confusing and lake no sens to me for(k=0;k
7 Jul 2017 by CPallini
The initialization of the matrix is incorrect (not complete). Moreover your sort routine is flawed. Try #include using namespace std; int main() { int a[5][5],i,j,k,t; int * b = reinterpret_cast(a); for(i=0;i>a[i][j]; } ...
7 Jun 2017 by Member 13246365
This is my function void clear_up(MatrixXd A, int dim) //to set all initial values of the matrix to 0 { for(int i=0;i
7 Jun 2017 by Patrice T
Quote: However, when I run it in a loop, some matrices are symmetric whereas some are not. What could be the reason? Serious ? you did not even dared to give an example of the problem. The minimum is an example with calling sequence to reproduce the problem. There is a tool that allow you to...
7 Jun 2017 by OriginalGriff
Quote: Compiling does not mean your code is right! :laugh: Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English, rather than German for example - not that the email contained the message you wanted to send. ...
4 Jun 2017 by Mosi_62
Some ways to solve a matrix equation :-)
10 May 2017 by Member 13191541
In R programming - How do I plot a network visualization graph given a matrix X with a 2 column coordinate system: coordinates
18 Apr 2017 by Bhola Ram Sahu
I want to do a small program that calculates eigen value and eigen vector in parallel processors using MPI. I have written a code that works correctly but its for uni processor. Please help me with some code for parallel processor. I want to compare the processing time for different number of...
30 May 2016 by Member 12550760
i want to get the inversion of n*n method so using augmented method so i made the identity matrix then made column reduction then found the inverse for(i=0;i
30 May 2016 by Kenneth Haugland
I have one way of solving the inverse of a matrix, solving it column by column:High precision native Gaussian Elimination[^]I also think you would benefit from reading up on matrixes in general, not just the inverse bit. Matrices are very useful in many areas, but mastering and...
6 May 2016 by Member 12508138
I created a program located at http://www.ptrone.com/ Where changing the value of z tocos(point)*120+120Creates a circle that is rotating in a circular motion. Can anyone tell the formula to create a triangle that rotates in a circular motion?What I have tried:cos(), sin(), exp()...