Rails `require’: cannot load such file — matrix

Matrix was removed from Ruby’s standard library in version 3.1. More info: https://www.ruby-lang.org/en/news/2021/12/25/ruby-3-1-0-released/ With Ruby 3.1, matrix needs to be explicitly added to the Gemfile. You can add it manually or run something like: $ bundle add matrix After it’s added to the Gemfile, bundle your application: $ bundle install Then your application should continue … Read more

Adding row/column headers to NumPy arrays

With pandas.DataFrame.to_csv you can write the columns and the index to a file: import numpy as np import pandas as pd A = np.random.randint(0, 10, size=36).reshape(6, 6) names = [_ for _ in ‘abcdef’] df = pd.DataFrame(A, index=names, columns=names) df.to_csv(‘df.csv’, index=True, header=True, sep=’ ‘) will give you the following df.csv file: a b c d … Read more

How to find linearly independent rows from a matrix

First, your 3rd row is linearly dependent with 1t and 2nd row. However, your 1st and 4th column are linearly dependent. Two methods you could use: Eigenvalue If one eigenvalue of the matrix is zero, its corresponding eigenvector is linearly dependent. The documentation eig states the returned eigenvalues are repeated according to their multiplicity and … Read more

Hungarian Algorithm: finding minimum number of lines to cover zeroes?

Update I have implemented the Hungarian Algorithm in the same steps provided by the link you posted: Hungarian algorithm Here’s the files with comments: Github Algorithm (Improved greedy) for step 3: (This code is very detailed and good for understanding the concept of choosing line to draw: horizontal vs Vertical. But note that this step … Read more

Semicolon on a function parameters

It is a seldom-used feature from C99 GNU extension (GCC documentation) that is used to forward-declare parameters used in VLA declarators. matrix_* matrix_insert_values(int n; double a[][n], int m, int n); Do you see how int n appears twice? The first int n; is just a forward declaration of the actual int n, which is at … Read more

Is there a standard solution for Gauss elimination in Python?

I finally found, that it can be done using LU decomposition. Here the U matrix represents the reduced form of the linear system. from numpy import array from scipy.linalg import lu a = array([[2.,4.,4.,4.],[1.,2.,3.,3.],[1.,2.,2.,2.],[1.,4.,3.,4.]]) pl, u = lu(a, permute_l=True) Then u reads array([[ 2., 4., 4., 4.], [ 0., 2., 1., 2.], [ 0., 0., … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)