[Solved] Browse a matrix

Here the solution I found : private static IEnumerable<int> ComputeMatrix(int[,] matrix) { // check args if (matrix.Rank != 2) { throw new ArgumentException(“matrix should have a rank of 2”); } if (matrix.GetUpperBound(0) != matrix.GetUpperBound(1)) { throw new ArgumentException(“matrix should have the same size”);} // indice treated List<int> treatedIndex = new List<int>(); for (int i = … Read more

[Solved] C# Console Application program to Create a user defined matrix and find Lowest number [closed]

Put this outside your “main” method to get make sure the user gives a number. private static int GetNumber(string request) { bool succeeded = false; Console.WriteLine(request); string reply=””; while(!succeeded) { reply = Console.ReadLine(); try { int.Parse(reply);//Attempt to convert “reply” into an integer. succeeded = true; } catch { Console.WriteLine(request+” (make it a number)”); } } … Read more

[Solved] Processing the data in a matrix in r [closed]

NOTE: Your question as it stands is not appropriate for this site. You should include a minimum reproducible example. Include code that you’ve tried and where it’s causing you trouble. At this point, you’re likely to continue getting down votes, and your question may potentially get closed. Be aware of that. Please visit the help … Read more

[Solved] c program to print min number of days required to spread rumour in matrix [closed]

The fastest way that the rumour will travel is when the roumor starts in the middle of the matrix. Since it travels only horizontally or vertically, if it starts from the middle then it will take m/2 + n/2 days to reach a corner in the worst case. Just try this printf(“%d\n”,m/2+n/2); it should work. … Read more

[Solved] can’t multiply matrix and list which type ‘float’

You are multiplying a list by a float. You should multiply each row of the matrix with words. Something like this will work. multiply_nonspam_test = [] for row in transpose_test_feature: multiply_nonspam_test.append([x*y for x,y in zip(row, log_train_probs_nonspam_words)]) print multiply_nonspam_test 0 solved can’t multiply matrix and list which type ‘float’

[Solved] Convert Matrix to Vector [closed]

Your problem is a very specific one. I don’t see how this will be of any use to anybody but yourself. There is no ‘one line solution’. There are many ways to approach indexing problems, I like to use scalar indexing when possible: Ncolumns = size(Matrix,1); Nblocks = floor(Ncolumns/4); %number of 4-line blocks (excluding the … Read more

[Solved] Convert text file to matrix [closed]

I will try to guess what is asked. Assuming that your data frame is named df, you can convert each column to matrix and put it in list using lapply(). For example, I converted to matrix with two columns. seq_len(ncol(df) will make sequence of numbers from 1 to number of columns, so conversion will iterate … Read more

[Solved] Finding subsets of a set of vectors that fulfill some conditions

The question is a bit complicated and hard to follow.. Anyways I tried writing some code to the best of my understanding of the problem. Here is the part that finds the possible combinations: % input matrix A=[1 2 0 1 2 0 0 0 2 1 1 1 0 2 2 0 3 0 … Read more

[Solved] Read text files long text file in python

You have the # lines as a separation between your matrix. So if you loop line by line on your file, you can separate the matrix with this # lines, and built them : file = open(“file.txt”, “r”) lines = file.readlines() At this point, lines is a list. lines[i] is the line n° i+1 as … Read more

[Solved] How to multiply two matrices having fractions as inputs in c [closed]

I wanted to use my own implementation of the Strassen optimization for matrix multiplication. It is highly optimized and hence has almost no pedagogical use but then I remembered that Wikipedia has actual C code in the Strassen-matrix-multiplication entry. The implementation there is not the best: it has no fallback to the naive algorithm if … Read more