Most voted "matrix" questions
An array is a collection of variables of the same type, accessible with a single name and stored contiguously in memory. The individualization of each variable of a vector is done through the use of indexes. Vectors are matrices of a single dimension.
Learn more…508 questions
Sort by count of
-
41
votes2
answers1150
viewsHow to count the objects present in the image with PHP?
The original photo of the bean is this: It lowers the resolution of the photo, I’ve already applied a grey-scale filter and increased the contrast to maximum to turn black and white. Then I examined…
-
21
votes2
answers4166
viewsWhat is the difference between array and matrix?
After seeing arrays and programming matrices, I got a little confused, so I was wondering, what’s the difference between a array and a matrix?
-
11
votes2
answers2189
viewsHow to calculate the determinant of a javascript matrix?
Ex.: det([-1, -2, 3], [3, 3, 1], [-1, 2, -3]) // retorna 22 Ex.: det([1, 2], [2, 5]) // retorna 1 Ex.: det([8]) // retorna 8
-
8
votes1
answer410
viewsMatrix parameter passing error
I am trying to understand the function of pointers for an array. For this, I have elaborated the small program below. I made some mistake, because, in the indicated line, error is occurring…
-
8
votes1
answer7678
viewsHow to make a function within a function return a vector?
I have a job for my course, and it is necessary to make a program similar to the game of megasena. It’s almost done, but I’m finding a small problem and I need help. Job dice: maximum 10 players can…
-
8
votes1
answer2823
viewsWhat does i-esimo mean in an array?
Which means i-th, I’m having a hard time understanding its use in arrays and matrices.
-
8
votes3
answers440
viewsGet the elements around a selected in the matrix
The idea is to create an integer array with the amount of user-defined rows and columns. Then an existing value in the matrix must be informed and the program must return the values immediately to…
-
7
votes1
answer424
viewsvector moving mean of a matrix in R
I’m doing the following operation with a matrix in the R: > m <- matrix(1:9, ncol = 3, nrow = 3) > m [,1] [,2] [,3] [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 > m2 <- m > for(i in…
-
7
votes3
answers68693
viewsHow to create a python array
I want to create an array where the user specifies the number of rows and the number of columns. Initially an empty matrix was given: matrix = [] The codes must start from there the code below was…
-
7
votes1
answer7242
viewsString matrix
How a matrix of strings? I tried it in several ways and still did not succeed, I thought it would work but it did not work. #include <stdio.h> #include <stdlib.h> int main(void){ char…
-
7
votes2
answers87
viewsSomatoria accumulating columns in a Matrix in R
I have the following situation : In a numeric type Matrix : Temp <- matrix(runif(25, 10, 100),nrow=5,ncol=5) V1 V2 V3 V4 V5 11 34 45 54 55 16 21 45 75 61 88 49 85 21 22 12 13 12 11 10 69 45 75 78…
-
7
votes1
answer861
viewsFill char matrix with random words
I’m trying to develop an algorithm that can get an array of strings, sort by word size downwards, and put them into a char matrix by fitting all the words together if possible. The idea of…
-
7
votes1
answer213
views -
6
votes2
answers381
viewsCreate new matrix from a fairly large first efficiently
Guys, in R, I have a very large database and want to create new columns. I will try to explain my problem with a very small matrix. Next, "1" means private school and "2", publishes. I have for…
-
6
votes1
answer139
viewsHow to convert a Javascript array to a PHP array?
The system gives me a Javascript matrix to work on the page. I can get this array with PHP, but I don’t know how to convert Javascript to PHP and work using PHP. This is an example of the Javascript…
-
6
votes1
answer2747
viewsRaw Strength Algorithm for Sudoku Game Resolution in C
I have the following code written in C: #include <stdio.h> #include <stdlib.h> #include <time.h> // Variáveis globais int jogo_tabuleiro[9][9] = {0}; int func_quadrante(int…
-
6
votes2
answers119
viewsWhat’s going on in my C program?
I just have to add the lines but the values don’t make sense: Here the code: #include <stdio.h> #include <stdlib.h> int main (){ int matriz[6][6],i,h,somalinha[6]; for(i=0;i<=4;i++){…
-
6
votes5
answers96
viewsMatrix with out-of-range index returning correct values
I was trying to create a matrix using while and realized that the program displays all the elements correctly if I just increment the value of j (column) up to 8. The program was not supposed to…
-
5
votes1
answer322
viewsCreating a matrix with variables with different correlations in R?
I need to generate data series that have correlations defined using R. I used a method I found here in the OS (How to generate correlated variables in R?) and I was able to create the variables with…
-
5
votes1
answer445
viewsHow to apply/search for global/local transformations in Opengl
I am programming a simple Game Engine using the graphical API Opengl. But I have a problem that I can’t solve. The problem is that the transformations in world (world) do not work properly. The…
-
5
votes1
answer31551
viewsPass matrix as function parameter?
I’m studying Dijkstra’s algorithm and I haven’t tried using adjacency lists yet. I knew I could solve the problem with a matrix, but the fact is that I can not receive the matrix in the function. If…
-
5
votes1
answer122
viewsComparison of two matrices with different sizes
I have two matrices with these dimensions and would like to remove the common lines between the two matrices and form another matrix without these elements. How R could do that? a = matrix(1:30,…
-
5
votes1
answer408
viewsOperations on matrix with no defined size
I need to perform operations on a matrix that will be passed by parameter, the problem is that its size is not fixed so I do not know how to perform the loop to go through the end of a column or row…
-
5
votes1
answer179
viewsSegmentation fault: branch and bound in c
I have a persistent error in my code. My goal is to find the way in a maze mounted on an array with an algorithm like branch and bound. Follows the code: FILE *ent; FILE *saida; int NL; int temp;…
-
5
votes1
answer1926
viewsHow to declare and initialize two-dimensional matrices?
I have to save the row, column and contents of a spreadsheet. For this I created a two-dimensional matrix. My difficulty is how to initialize it? I believe the statement is no longer correct because…
-
5
votes1
answer492
viewsOperation with three-dimensional arrays
Reformulating the question, I would like to implement the following equation: Where D is a matrix of order i x k x l, lambda is a matrix k x j and pk = {1,2,3,4,5,6}. For this I need some function…
-
5
votes1
answer2161
viewsConcatenate two columns of an array into a string of characters
Suppose I have the following vectors: n <- c(1:5) c <- c("A","B","C","D","E") I build the following matrix with them: m <- matrix(c(n,c), ncol = 2) What is the best way to obtain such a…
-
5
votes2
answers695
viewsPHP Matrix How to Fill
Guys want to fill this matrix. It works but when I try to put more than one result in the same line only the last one appears. How to fix? <h1>Mapa</h1> <?php $linha=0; $coluna=0;…
-
5
votes3
answers6933
viewsRotate matrix by 90º
I need to create a C algorithm to rotate a 10x10 matrix by 90 degrees, however I cannot use an auxiliary matrix for this. Simplifying what was asked to try to find some pattern and use it to solve…
-
5
votes1
answer2733
viewsCalculating a magic square
I’m trying to make a magic square: A magic square is one divided into rows and columns, with a number in each position and in which the sum of the rows, columns and diagonals is the same. Example…
-
5
votes2
answers1986
viewsDiagonal matrix in java
First, I would like to inform you that I am new here on the site, and if by chance my question was left without information or badly organized please speak. I was trying to solve that question: I…
-
5
votes1
answer1239
viewsWhat is an Adjacency Matrix?
Whenever read something in relation to graph theory I stumble upon a term called Adjacency matrix, it seems to me that this is strongly related to this theory. Therefore, I would like to know more…
-
5
votes2
answers9758
viewsPass matrix as pointer
I need to make the proposal: Elaborate a function that takes as parameters a pointer of an array, the number of rows and columns, and print the matrix elements. But I am learning pointers and having…
-
5
votes4
answers5739
viewsHow to separate the letters of a string that are inserted into a list and place them in an array?
I have a list with the word "test", arranged in such a way: ['teste','teste','teste','teste','teste'] I would like to turn this list into a matrix, in which the letters are separated from each…
-
4
votes5
answers2024
viewsReplace If/Else with Case javascript
I would like to replace if/Else with Case because I believe it will be better for understanding the code since it will be a little long, but I cannot access the Array that will have the conditions…
-
4
votes2
answers6494
viewsHow to create inverse matrix in R
To get the inverse of an array, we can use different R commands solve(), ginv(), etc, however, when trying to use these commands, an error occurs where we think the problem should be because there…
-
4
votes2
answers97
viewsSubtracting matrices with different arguments
We can subtract two matrices (or two vectors) that were written with different commands? Example: x<-array(1:4,c(4,1,1)) y<-cbind(c(1:4)) x-y "Error> non-conformable objects" This means…
-
4
votes2
answers5586
viewsHow to move, rotate or scale an Object on its local axis in Opengl?
Hello, I have a class HTransform which stores a matrix, position, orientation and scale of each object, this class is the base class of each Object or entity. I made one function to move the Object…
-
4
votes2
answers106
viewsData window moving in time (t)
I want to make a recursive prediction. I need each month (t) to move the data window of the last month forward in a period (monthly period, that is, t+1).…
-
4
votes2
answers185
viewsHow to pass an array as argument with the user defining the column number?
I’ll make a simple program just to illustrate my problem. #include<iostream> using namespace std; void recebeValor( int mat[][col]) // me da erro de comp; { mat[0][0] = 2; cout <<…
-
4
votes3
answers1099
viewsHow to divide the elements of a matrix by the average of its column
I need to divide the elements of a matrix by the respective average of its column, as I can do this, there is some function to perform this simple operation? Considering the matrix: > A <-…
-
4
votes3
answers756
viewsGet larger number of items in a Python list array
I have a Python array composed of arrays. But these arrays can have different sizes. For example: matriz = [[1,2,3],[4,5,6,7],[1,2,3,4,5,6]] What I want to know is if there is a medium (some python…
-
4
votes1
answer185
viewsSet using matrix in c#
I have the following matrix: a d k m s j e r t c f p I put such a matrix in an array as follows: char[,] matriz = new char[3,4]; matriz[0,0] = 'a'; matriz[0,1] = 'd'; matriz[0,2] = 'k'; matriz[0,3]…
-
4
votes1
answer799
viewsUsing the lower triangularization method calculate the determinant of a transposed matrix
Using the lower triangularization method, I have to calculate the determinant of a transposed matrix. I want, from the transposed matrix, to calculate the determinant using the inferior…
-
4
votes0
answers102
viewsCreate an array/Arrays based on a TXT file
I am new to using the Fortran/95 language and want to extract some data from a txt file (http://1drv.ms/20gSNKb), are flow data available in the Hidroweb portal. Whereas they are separated by ";" as…
-
4
votes1
answer2932
viewsCalculate covariance matrix in R
Given a matrix whose elements are values of a given attribute in n positions in space. How to calculate the covariance matrix (nxn) of the values of this attribute at the given positions?
-
4
votes1
answer505
viewsSearch Matrix index from json value using the index
I have the following matrix: var usuarios = [ {nome: "João", id: 1}, {nome: "Maria", id: 2}, {nome: "José", id: 3}, {nome: "Ana", id: 4}, ]; I need to return the José user index. I tried using the…
-
4
votes1
answer224
viewsHow to add values to an array of a Ruby array?
puts "Alunos\n\n" alunos = [["Daniel: ", "Nota: 10\n\n"],["Abima: ", "Nota: 10\n\n"], ["Wilame: ", "Nota: 10\n\n"],["Felipe: ","Nota: 10\n\n"]] puts alunos I wonder if it is possible to add a new…
-
4
votes1
answer73
viewsMake a matrix of origins and destinations
I need to fill a table with origins and destinations so that each cell contains the total number of people leaving from one location to another. The database has an id for each observation, as well…
-
4
votes2
answers385
viewsProblem with C matrices
I have to do a program that will read 4 grades from each of the 6 students in a class and store them in a matrix NOTES[6][5]. For each student, the arithmetic mean of the 4 grades should be…