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
-
2
votes1
answer3712
viewsHow to scroll through a 2-dimensional matrix in C and display?
In this code, I have a two-dimensional array(array), I started and I want to print with the printf, but I don’t know how: #include <stdio.h> #include <stdlib.h> int main() { int i; int…
-
2
votes1
answer102
viewsReturn a Matrix that has all possible column multiplications of another Matrix (R)
Be a Matrix : bb=replicate(3, rnorm(3)) [,1] [,2] [,3] [1,] 0.5556358 1.6611142 0.2374830 [2,] -0.6672456 -0.5038430 0.9814712 [3,] -0.1391022 -1.2072500 -0.6219965 How can I return a second matrix…
-
2
votes1
answer90
viewsHow do I avoid infinite loopings in an array?
"Mount an F matrix of size n x n representing a forest. Each element of this matrix can have 3 values: 0 - if empty 1 - contains a tree 2 - contains fire With probability p, given by the user, put a…
-
2
votes0
answers61
viewsHow does the apply family work?
would like to know how the functions of the apply family work and if possible with examples. In what contexts best apply? Thanks since then!
-
2
votes1
answer44
viewsBertin Matrix installation problem
I’m trying to download a package from R which is called the Bertin matrix. The address I have is http://bertin.r-forge.r-project.org/. The problem that when I try to download comes a message that…
-
2
votes1
answer2466
viewsEmpty list matrix initialization "{ }" in C++
From what I have seen, it is possible to initialize a vector with the empty list, in C++, but not in C, so that all vector elements are 0: int meuVetor[10] = {}; // Todos os elementos 0, em C++ What…
-
2
votes1
answer102
views -
2
votes1
answer84
viewsMessage at the end of na.omit
I’m using the remote na.omit(matrix.work) and the message appears at the end: attr(,"na.action") [1] 3 11 attr(,"class" Does anyone know how to delete this message, because I don’t want it to appear…
-
2
votes1
answer85
viewsOperation with large matrix
Staff would like to know how I can make the Euclidean distance squared between the octadimensional vectors of b and those who are not in a in a super matrix like this of the example. I thought so…
-
2
votes2
answers131
viewsWhat is the limit of multidimensional vectors?
I’m doing a test and it gives me an error when I try to create a vector[1000][1000]. There are limits to vectors? The error code (application ceases to respond) is the following: int main (){ int…
-
2
votes2
answers1175
viewsFind a particular line or specific value of a matrix vector in R
How to build a function that evaluates if any row of the matrix mat is equal to the vector vec both in the code below: set.seed(000) mat <- matrix(rnorm(20),4,5) vec <- c(1.3297993,…
-
2
votes3
answers1025
viewsproblem in C with rest of the division
Develop a program that scans ten elements of an A-matrix vector type. Construct a matrix B of the same type, observing the following law of formation: if the value of the index is even, the value…
-
2
votes2
answers1818
viewsSearching for a matrix within another matrix in Java
I need to compare two two-dimensional matrices (int[][]) of different sizes, the two being formed by integer values (1 or 0), to verify if there is the smaller matrix within the larger matrix.…
-
2
votes1
answer794
viewsHow to generate Adjacent Matrix of a BFS from a txt file? C++
I’m using the Codeblocks. I have a. txt file that represents a maze, everything that is after the : are rooms: The first line of the file shows the start coordinate, which in this case is AS. Every…
-
2
votes1
answer722
viewsAdd values within the Two-Dimensional Matrix from the line the user chooses
In the exercise I had to create a two-dimensional matrix and then when the user typed 0, 1 or 2 to know the matrix line, I should add the line values and show the result. I wonder if inside the…
-
2
votes1
answer38
viewsHow to turn a query row into columns and group according to the first 4 characters?
I would like to transform the return of my SQL query into an array where I select the first four characters, which will act as a kind of group, and return the values for that group in columns. I’m…
-
2
votes1
answer4081
viewsHow to break a list and turn it into an array in Python?
In case, I want to turn a list of a column into a 3x3 matrix in numerical order: lista =([[1], [2], [3], [4], [5], [6], [7], [8], [9]]) With the expected result: ([[7 8 9] [4 5 6] [1 2 3]])…
-
2
votes3
answers687
viewsHow to join values in common php array?
I have the array $vetor[0]['codigo'] = '1'; $vetor[0]['valor'] = '4'; $vetor[1]['codigo'] = '1'; $vetor[1]['valor'] = '2'; $vetor[2]['codigo'] = '2'; $vetor[2]['valor'] = '2'; I need to merge all…
-
2
votes1
answer1905
viewsSet the shortest path in graphs
Hello, I’m starting to see graphs now, I’m trying to create a program where the user enters with an adjacency matrix and the program calculates the shortest possible path from the initial node to…
-
2
votes1
answer1039
viewsC++ - Convert Mat to Opencv integer array?
I’m doing an image manipulation project using the Opencv. I need to analyze the values of pixels of a "binarized" image, for this I am trying to convert my Mat file image to a array of integers,…
-
2
votes1
answer396
viewsVector and matrix ordering
Do you have another method to sort vector/matrix in ascending or descending order other than the one I used ? ( What would you change in this code to make it " better " ? ) #include <stdio.h>…
-
2
votes4
answers295
viewsPrint null or non-null in Python array
If matrix has only zero print 'null' if not print 'not null' I did so: m=[[0,0,0],[0,0,0],[0,0,0]] soma1=0 for novo1 in m[0]: soma1+=novo1 soma2=0 for novo2 in m[1]: soma2+=novo2 soma3=0 for novo3…
-
2
votes1
answer887
viewsMatrix multiplication by matrix transposed in C language
I am new to programming and I am trying to make a program in C language that multiplies a 3x3 matrix by transposing it and prints the result. I’m having a hard time creating a multiplication…
-
2
votes2
answers2462
views -
2
votes2
answers10163
viewsHow to make the rest of the division of a float by a number in c?
I am beginner in programming in c, I have here a problem the exercise and calculate the average of the odd in a matrix that receives real numbers. However, I’m having the following mistake: error:…
-
2
votes1
answer100
viewsHow to replace a float element with a string in a zeroed array?
I generated a zero matrix through the code: import numpy as np lista = np.zeros([4,4]) Later, I tried to replace an element of the matrix with some string (for example "a"). However, I made an…
-
2
votes0
answers396
viewsLimit use of RAM in R
I’m running some analysis and would like to fix the use of RAM in R to be able to use other software simultaneously without any problem. So I’d like to, for example, limit the 4gb of RAM memory,…
-
2
votes2
answers105
viewsError trying to imprint the return of a two-dimensional matrix
I’m trying to print a two-dimensional matrix through a loop for only that the matrix it is returned through a function that I created. I’m suspecting that the mistake must be found in it but I’m not…
-
2
votes2
answers454
viewsInserting index and value into a two-dimensional array
I have a two-dimensional array (it contains data from the database). To go through this data, I use a foreach(). I need to add an index and a value to that index at the end of each foreach…
-
2
votes2
answers2051
viewsMatrix multiplication in Java
I need to make two matrices multiply, but I’m wrong when it comes to multiplying. int ma[][] = new int [3][2]; int mb[][] = new int [2][2]; int mab[][] = new int [3][2]; for (int i = 0; i <…
-
2
votes1
answer512
viewsHow to delete characters from a string within a Python array
I’m starting in python and decided to mess with files .txt. I did the following procedure to insert values into an array, and from it insert each value into a row of a file filename.txt. def…
-
2
votes1
answer300
viewsBreak text and vector store
I want the program to be able to store only one sentence per line. Each sentence is possible to be completed according to the signals I show in my code example. It does this but when printing on the…
-
2
votes2
answers165
viewsHow can I get the highest value of a matrix with Lambda function in Python
In a list it is possible with the method "reduce" to achieve the highest value, but in a matrix I am not able to obtain the highest value of it: from functools import reduce matriz = [[4, 2, 56],…
-
2
votes1
answer199
viewsHow to transform more than one vector into an array using the php language?
I have a file matriz_caminhos.txt with 20 rows and 20 columns, I need to access it and take the data as an array. So far, I just got it to scan the file and return me 20 vectors. Follows the code: .…
-
2
votes2
answers2568
viewsChange the value of a number in a matrix without knowing the position (index) in Python
Hello, How do I change the value of a number in a matrix when I don’t know what its index is and there might be more than one value to change? For example, if I have the matrix: [[4,5,3,15,4],…
-
2
votes1
answer99
viewsHow to run a looping in R and store the results of a summary in a vector
I asked a previous question in this forum (Random choice of lines in an array in R) where it needed to randomly choose p lines (p < m), without replacement, of this matrix. Thus creating a matrix…
-
2
votes1
answer296
viewsHexagonal matrix in Python
I would like to know how to return the numbers of a vector (matrix) within a specific R (radius) using Python. Follow on this image: Following the vector used: mapa = [ [0.0, 0.1, 0.2, 0.3, 0.4,…
-
2
votes1
answer1711
viewsSimple text editor in C
I have the following exercise proposed: Make a program that mimics a text editor. Initially you will read the data typed by the user (lines of text) and create a vector in memory where the texts…
-
2
votes1
answer1652
viewsProgramming C - Swap matrix elements
My code below should exchange the elements of the matrix, if it is 1 will exchange for 0 and if it is 0 will exchange for 1. However the printed matrix is with all elements 0: #include…
-
2
votes2
answers111
viewsPointers and matrices catching something unexpected
#include <stdio.h> int main() { int vetor[][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; int valor= *(vetor[1] + 1) + **(vetor + 3); printf("%d", valor); } The code above was taken from…
-
2
votes2
answers142
viewsError summing each row of a 5x3 matrix
Hello, I’m having a problem adding up each of the lines of my matrix and storing in a vector my code is like this: #include <stdio.h> int conta(int * matriz[5][3], int * vet) { for (int i = 0…
-
2
votes1
answer1852
viewsDefine matrix in python
I need to create a matrix and fill it with random values (randint(0,9)), except in equal rows and columns. For example, in this way: A| B| C| D| E A x| 2| 1| 4| 2 B 1| x| 1| 1| 2 C 5| 1| x| 4| 3 D…
-
2
votes1
answer86
viewsRead matrix elements and print them
I created an algorithm that would receive a single variable with 9 different records that would display these values typed in matrix form (table). But when displaying the result, it is only…
-
2
votes1
answer111
viewsEfficient method to lower array order in PHP
I’m developing a determinant calculator in PHP In the Matrix class I created some functions, among them the function Calc(order, matrix). This function calls another to lower the array order to…
-
2
votes1
answer1308
viewspython game of checkers
i have an array of a checkers game state, how can I know which pieces are threatened on the board? X5 is the threatened black parts and X6 is the threatened red parts, ie I want to know how to…
-
2
votes2
answers109
viewsC Programming - Two-Dimensional Matrices
**Matrix Print Error.Cannot generate matrix lines. Note, without using another library** #include <stdio.h> int main() { int nlinhas,mcolunas; int matriz[nlinhas][mcolunas]; int n,m;//n…
-
2
votes1
answer106
viewsError searching row inside matrix
The exercise asks me to create matrices to store aircraft registration with some variables, done this, the program asks me to search all the information by entering the code. The problem is that…
-
2
votes1
answer61
viewsProcedure runs alone -Pascal
I made a code in pascal that reads two images type pgm and checks if one is contained in the other, but when reading the second image, instead of reading the program simply warns that the type of…
-
2
votes1
answer140
viewsArray problem in C, where is the error?
I have the following problem to solve: I arrived at this solution: #include <stdio.h> int main() { double numeros[99]; double resultante[49]; int i, j; for (i = 0; i <= 99; i++) {…
-
2
votes2
answers87
viewsCreate a matrix without repeating the values of the date argument
Hello, I have the following code M <- matrix(data = c(1,2,3,4,5), nrow = 5, ncol = 5, T) It produces the following output: [,1] [,2] [,3] [,4] [,5] [1,] 1 2 3 4 5 [2,] 1 2 3 4 5 [3,] 1 2 3 4 5…