Hot answers tagged

11 votes

Nonnegative Least Squares Algorithm (NNLS)

We can compare 6 algorithms based on FindMinimum,NMinimize, ConvexOptimization, ...
user avatar
  • 34.1k
11 votes

Is it possible to use the DGEEV and DSYEV LAPACK subroutines in Mathematica?

You can use LibraryLink to call LAPACK directly. It involves however quite a lot of boilerplate code. Here is an example: ...
user avatar
8 votes
Accepted

How to obtain independent variables from a set of linear constraints

First one can set up and solve the system. ...
user avatar
7 votes

How to replace anti diagonal elements of a matrix

From The Procedural Dodo: If you can do it in place (destroying the orginal m), this will be fast: ...
user avatar
  • 216k
7 votes
Accepted

Matrix Integro-differential equation

The problem can easily be solved after reformulation to a system of ODEs. Let us start with $$ \frac{d\rho}{dt}=-i[H_{0}(t),\rho(t)]-A^{2}\Big[H_{1},\int_{t1}^{t}e^{-B(t-s)}\Big(e^{-i\int_{s}^{t}H_{0}(...
user avatar
  • 16.1k
5 votes

How to export a matrix in mathematica to some format so that I can read it in python using numpy array

One easy way is python pickle; before that, we should convert your data to a format readable by sympy. here are the steps: ...
user avatar
  • 5,444
5 votes

How to replace anti diagonal elements of a matrix

Using ReplacePart: ...
user avatar
5 votes
Accepted

How to replace anti diagonal elements of a matrix

This is the kind of question that might trigger the "how-many-ways-can-you-do-it" game. I'll kick it off with this: ...
user avatar
  • 5,429
5 votes
Accepted

Does converting large 3D matrices to VERY large 2D matrices affect speed of operations done on the matix?

There's no appreciable difference in memory usage, for either unpacked or for packed arrays: ...
user avatar
  • 216k
4 votes

Finding eigenvectors of a symbolic matrix

Here is one, not particularly sophisticated, approach using Normalize. You could use evs = Map[Normalize,Eigenvectors[{{a,b},{b,-a}}]]; to get normalized ...
user avatar
4 votes

How to replace anti diagonal elements of a matrix

We can subtract the anti-diagonal to remove it and then add the Reverse of diagonal. ...
user avatar
  • 33k
4 votes

How to obtain independent variables from a set of linear constraints

...
user avatar
  • 121k
4 votes

How can I generate a tridiagonal block matrix?

It must be many ways to do this,here we provide one way. ...
user avatar
  • 33k
3 votes

How to create a matrix with multiple variables defining the elements?

Array[f,{3,3,3,3},{0,0,0,0}] will give you a 4-dimensional matrix. f@@@Tuples[{0,1,2},4] will give you a 1-dimensional list. ...
user avatar
  • 5,429
3 votes

How to find the index of a square matrix in Mathematica quickly?

In version 13.0.1, there is a undocumentation function LinearAlgebra`MatrixIndex. But I'm not sure when this is introduced ...
user avatar
  • 23.7k
3 votes
Accepted

Convert List to Matrix

Clear["Global`*"] (mat = RandomInteger[200, {3, 3}]) // MatrixForm Note that the MatrixForm wrapper is isolated ...
user avatar
  • 121k
3 votes

Solution to a linear equation with minimum rank

Your transposed equation looks like Transpose[M].Transpose[X]==Transpose[A] LeastSquares finds the minimal solution ...
user avatar
3 votes

How to replace anti diagonal elements of a matrix

idm = IdentityMatrix[Length@m] (res = Reverse /@ (m idm) + m (-(Reverse /@ idm ) + 1) ) // MatrixForm $$\left( \begin{array}{ccccc} 100 & 9 & 3 & 8 &...
user avatar
  • 16.2k
3 votes

How to replace anti diagonal elements of a matrix

use element-wise operation. keep the diag-matrix and reverse it. anti = mat // Diagonal // (*take diag*) DiagonalMatrix // (*make mat*) Map[Reverse] (*rev it*) {...
user avatar
  • 6,817
3 votes
Accepted

How can I have Mathematica solve the curve equation when nested functions are involved?

You would have to come up with a model in order to fit those curves. No automated system can do that for you. However, that may not be the most useful approach. For instance some properties of the ...
user avatar
  • 60.4k
2 votes

How to replace anti diagonal elements of a matrix

Making use of the method posted by ciao (in an answer to How to zero (or replace) the diagonal of a square matrix?) ...
user avatar
  • 10.5k
2 votes

How to replace anti diagonal elements of a matrix

With[ {mask = Reverse[ReplaceAll[DiagonalMatrix[Function /@ Diagonal[m]], 0 -> Identity], 2]}, MapThread[Construct, {mask, m}, 2]]
user avatar
  • 5,429
2 votes

Solution to a linear equation with minimum rank

We can use Nonnegative Least Squares Algorithm (NNLS) discussed here to solve matrix equation X.M=A with constraints ...
user avatar
  • 34.1k
2 votes

How can I generate a tridiagonal block matrix?

The matrix you have is block tridiagonal and block Toeplitz. I'll give two methods: one that uses nothing but documented functionality, and one that uses undocumented functionality. First up is an ...
user avatar
1 vote
Accepted

Generalised KroneckerProduct that works like Outer[]

I'm not sure what to make of your KroneckerProduct comment, but I think what you're looking for is MapThread: MapThread[f, {matA, matB}, 2]
user avatar
  • 5,429
1 vote

Regression of a set of (2-element) vectors on another set of (2-element) vectors

I think you have three problems that get in the way of what I think you're asking. I think you want to perform a regression on the following model (which also isn't the model I think you should be ...
user avatar
  • 34.1k

Only top scored, non community-wiki answers of a minimum length are eligible