matrix

Whats wrong with the c code?

空扰寡人 提交于 2019-12-25 19:42:34
问题 #include<stdio.h> int findMax(int **a,int m,int n) { int max,i,j; max=a[0][0]; for(i=0;i<m;i++) for(j=0;j<n;j++) if(max<a[i][j]) max=a[i][j]; return max; } int main() { int a[20][20],m,n,i,j,maxim; scanf("%d",&m); //Rows scanf("%d",&n); //Cols for(i=0;i<m;i++) for(j=0;j<n;j++) scanf("%d",&a[i][j]); maxim=findMax((int **)a,m,n); printf("Max is %d\n",maxim); return 0; } The above code must give the maximum element in the input matrix. PROBLEM When the code is compiled, i'm not getting any error

Whats wrong with the c code?

流过昼夜 提交于 2019-12-25 19:42:14
问题 #include<stdio.h> int findMax(int **a,int m,int n) { int max,i,j; max=a[0][0]; for(i=0;i<m;i++) for(j=0;j<n;j++) if(max<a[i][j]) max=a[i][j]; return max; } int main() { int a[20][20],m,n,i,j,maxim; scanf("%d",&m); //Rows scanf("%d",&n); //Cols for(i=0;i<m;i++) for(j=0;j<n;j++) scanf("%d",&a[i][j]); maxim=findMax((int **)a,m,n); printf("Max is %d\n",maxim); return 0; } The above code must give the maximum element in the input matrix. PROBLEM When the code is compiled, i'm not getting any error

how can i create a matrix using vector with lag using matlab

血红的双手。 提交于 2019-12-25 19:03:46
问题 vector= 3 4 8 5 2 1 6 the matrix i want to create is 3 0 0 4 3 0 8 4 3 5 8 4 2 5 8 1 2 5 6 1 2 回答1: This was already covered in one of your previous questions. Although you aren't trying to create a square matrix in this example, you can still use the TOEPLITZ function like in Jonas' answer: M = toeplitz(vector,[vector(1) 0 0]); 来源: https://stackoverflow.com/questions/3357075/how-can-i-create-a-matrix-using-vector-with-lag-using-matlab

how can i create a matrix using vector with lag using matlab

北慕城南 提交于 2019-12-25 19:01:54
问题 vector= 3 4 8 5 2 1 6 the matrix i want to create is 3 0 0 4 3 0 8 4 3 5 8 4 2 5 8 1 2 5 6 1 2 回答1: This was already covered in one of your previous questions. Although you aren't trying to create a square matrix in this example, you can still use the TOEPLITZ function like in Jonas' answer: M = toeplitz(vector,[vector(1) 0 0]); 来源: https://stackoverflow.com/questions/3357075/how-can-i-create-a-matrix-using-vector-with-lag-using-matlab

Passing pointers (matrix) to a function in c [duplicate]

天涯浪子 提交于 2019-12-25 18:50:44
问题 This question already has answers here : Passing an array as an argument to a function in C (9 answers) Closed 3 years ago . I have dynamically created a matrix using calloc in the usual way: int **matrix; int dim,r; scanf("%d",&dim); matrix=(int **)calloc(dim, sizeof(int *)); for(r=0; r<dim; r++) { matrix[r]=(int *)calloc(dim, sizeof(int)); } Now if I wanted to create a function to just print the elements of this matrix, I should write something like: void stampmatrix(int **matrix, int dim)

Represent a sparse matrix in C using the CSparse Library

巧了我就是萌 提交于 2019-12-25 18:37:35
问题 I can't understand how can easily represent a sparse matrix in C using the CSparese Library. That's what I want | 6.0 0.0 2.0 | A = | 3.0 8.0 0.0 | | 6.0 0.0 1.0 | with | 40.0 | b = | 50.0 | | 30.0 | The cs Struct of the csparse is this typedef struct cs_sparse /* matrix in compressed-column or triplet form */ { csi nzmax ; /* maximum number of entries */ csi m ; /* number of rows */ csi n ; /* number of columns */ csi *p ; /* column pointers (size n+1) or col indices (size nzmax) */ csi *i ;

Creating a symmetric matrix

ぃ、小莉子 提交于 2019-12-25 18:32:42
问题 I want to learn how to create a symmetric matrix in VBA. For example in the first step I want to choose Range("C3:I3") then copy to the Range("B4:B10") . In the second stage it should choose Range("D4:I4") then copy to the Range("C5:C10") . It should go on like that. 回答1: I have some code to do it. Your selected cell must be within the range of numbers. 1. If the diagonal line is empty. ► The code: Sub making_symmetric_matrix() Dim i As Long, j As Long Dim rng As Range Set rng = Selection

Trying to reload an operator in c++, but it doesn't seem to work

强颜欢笑 提交于 2019-12-25 18:30:18
问题 Problem: I have overloaded operators * and *= with the same solution, though using operator *= doesn't seem to change the contents of the Matrix, maybe I am declaring the operator overload method incorrectly. At the same time, operator * works properly and actually multiplies Matrix, I have checked it beforehand. Output: 3 4 -5 8 0 7 8 9 -4 8 7 7 -6 0 6 2 2 9 3 4 -5 8 0 7 8 9 -4 Here is the code itself: struct WrappedMatrix{ int n; int ** Matrix; }; struct WrappedVector{ int n; int * Vector;

A method to search Id inside a matrix -Trouble with output

北城以北 提交于 2019-12-25 18:29:42
问题 I am new at programming and I am trying to create a method that allows me search Id inside a [10,4] matrix, however I don't get how to do it without using nested fors and also if and else statement. The problem is related to output, I know the structure isn't correct, but since I don't what else can be done I am trying make it as it is: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace menu { class Program { enum

Computing time complexity of the sparse matrix (2)

余生长醉 提交于 2019-12-25 18:23:53
问题 I have a data set (D) of (nxd) where n=number of rows and d= number of dimensions, I create a similarity matrix (S)(nxn) by comparing each row of the data set (D) and then convert it into a sparse matrix (tx3) where t is the number of non-zero elements of the symmetric similarity matrix (S) The time complexity of creating the similarity matrix is o(n^2d) where d is some constant operation. The time complexity of converting a sparse matrix is theta(n^2) My question is: While creating the