Quantcast
Channel: Math.NET Numerics
Viewing all 971 articles
Browse latest View live

New Post: Transpose a vector

$
0
0
thank you for the help and the great explanation,
really fast and informative.
Thank you,
michael

New Post: Step function/interpolator

$
0
0
I implemented a piece wise constant interpolator. would you like to have it?

New Post: Transpose a vector

$
0
0
by the way, could you please help me with a matrix access?
How could i do this matlab syntax?
Mnew = M (:,2)
or
Mnew = M(3,3:6)

do have experiences here also?

michael

New Post: Transpose a vector

$
0
0
You can use the SubMatrix() method to extract contiguous slices.

New Post: Transpose a vector

New Post: Issues with f# sample code

$
0
0
Hi all,
I'm attempting to run this sample code copied from http://numerics.mathdotnet.com/docs/ in the VS interactive window. The code returns the following error:
The type referenced through 'MathNet.Numerics.LinearAlgebra.Matrix`1' is defined in an assembly that is not referenced. You must add a reference to assembly 'MathNet.Numerics'.
Any thoughts on what is going wrong? The dlls were acquired through nuget. They are version 3.0.2.
#r @"C:\path_to_dlls\MathNet.Numerics.dll"
#r @"C:\path_to_dlls\Mathnet.Numerics.FSharp.dll"
open MathNet.Numerics
open MathNet.Numerics.LinearAlgebra
open MathNet.Numerics.LinearAlgebra.Double
SpecialFunctions.Gamma(0.5)

let m : Matrix<float> = DenseMatrix.randomStandard 50 50
(m * m.Transpose()).Determinant()

New Post: How to apply operation over vector from each row/column of a matrix?

$
0
0
I have been porting some code that I had with my own Matrix<T> implementation but Math.Net is far more complete.

And I am wondering if there exists such a method here.
My code looked like this:

wu_v += Functions.Sum(v, Axis.Rows);

Where wu_v is a Matrix<T> and v is a Vector<T>. The alternative is to do:
wu_v = wu_v + ones * diag(v) or coding it by hand for performance, but I was wondering if there was such a construct already.

Federico

New Post: How to apply operation over vector from each row/column of a matrix?

$
0
0
Hi Federico,

I don't fully understand yet what the operation should do. What does Functions.Sum(v, Axis.Rows) do and how does it relate to ones * diag(v), exactly?

Maybe you're looking for FoldRows(f,state) which applies a binary function to each row vector of the matrix and a state vector (where the result becomes the state for the next row)? See also "Enumerators and Higher Order Functions" in Matrices and Vectors.

Thanks,
Christoph

New Post: Issues with f# sample code

$
0
0
The NuGet package contains builds for multiple platforms. Which one did you reference? Sounds a bit as if the .Net 3.5 assemblies had been referenced.

Thanks,
Christoph

New Post: Step function/interpolator

$
0
0
Great, thanks! I've cherry-picked the step but also the log-linear and transformed intepolators to mainline.

Thanks,
Christoph

New Post: Compiler error calling MathNet Numerics DelimitedWriter.WriteFile

Created Release: Math.NET Numerics v3.1.0 (Jul 20, 2014)

$
0
0
  • Random: generate a sequence of integers within a range in one go
  • Distributions: all distributions must have static routines to sample an array in one go
  • Linear Algebra: fix Matrix.StrictlyLowerTriangle
  • Linear Algebra: fix vector DoOuterProduct ~mjmckp
  • Linear Algebra: enumerators accept Zeros-parameter (like map/fold already does)
  • Linear Algebra: Vector.MapConvert (consistency)
  • Linear Algebra: proper term for 'conjugate symmetric' is 'Hermitian'
  • Interpolation: new Step, LogLinear and transformed interpolators ~Candy Chiu
  • Interpolation: check for min required number of data points, throw ArgumentException if not.
  • Root Finding: F# FindRoots.broyden module function ~teramonagi
  • Misc docs fixes

Released: Math.NET Numerics v3.1.0 (Jul 20, 2014)

$
0
0
  • Random: generate a sequence of integers within a range in one go
  • Distributions: all distributions must have static routines to sample an array in one go
  • Linear Algebra: fix Matrix.StrictlyLowerTriangle
  • Linear Algebra: fix vector DoOuterProduct ~mjmckp
  • Linear Algebra: enumerators accept Zeros-parameter (like map/fold already does)
  • Linear Algebra: Vector.MapConvert (consistency)
  • Linear Algebra: proper term for 'conjugate symmetric' is 'Hermitian'
  • Interpolation: new Step, LogLinear and transformed interpolators ~Candy Chiu
  • Interpolation: check for min required number of data points, throw ArgumentException if not.
  • Root Finding: F# FindRoots.broyden module function ~teramonagi
  • Misc docs fixes

3.0.2 - 2014-06-26:
  • Patch release, fixing a bug in Matrix.RemoveRow range checks.

3.0.1 - 2014-06-24:
  • Patch release, fixing a bug in new Matrix.ToMatrixString and Vector.ToVectorString routines.

Updated Release: Math.NET Numerics v3.1.0 (Jul 20, 2014)

$
0
0
  • Random: generate a sequence of integers within a range in one go
  • Distributions: all distributions must have static routines to sample an array in one go
  • Linear Algebra: fix Matrix.StrictlyLowerTriangle
  • Linear Algebra: fix vector DoOuterProduct ~mjmckp
  • Linear Algebra: enumerators accept Zeros-parameter (like map/fold already does)
  • Linear Algebra: Vector.MapConvert (consistency)
  • Linear Algebra: proper term for 'conjugate symmetric' is 'Hermitian'
  • Interpolation: new Step, LogLinear and transformed interpolators ~Candy Chiu
  • Interpolation: check for min required number of data points, throw ArgumentException if not.
  • Root Finding: F# FindRoots.broyden module function ~teramonagi
  • Misc docs fixes

3.0.2 - 2014-06-26:
  • Patch release, fixing a bug in Matrix.RemoveRow range checks.

3.0.1 - 2014-06-24:
  • Patch release, fixing a bug in new Matrix.ToMatrixString and Vector.ToVectorString routines.

New Post: How to apply operation over vector from each row/column of a matrix?

$
0
0
Probably FoldRows(f,state) is what I need to build it.

Function.Sum(v, Axis.Rows) looks like this (column-major):
 for (int majorItem = 0; majorItem < t.Length; majorItem++)
 {
     for (int i = 0; i < items; i++)
          t[majorItem] += mt[ptr + i * minorStride];

     ptr += majorStride;
 }
It treats every column of the matrix M as a vector mv and adds the vector v to it.
For every k in M
     mv = M.GetColumnVector(k);
     mv += v ;

New Post: How to apply operation over vector from each row/column of a matrix?

$
0
0
Ah, that looks more like:
m.MapIndexedInplace((i,j,x) => x + v.At(i));

New Post: How to apply operation over vector from each row/column of a matrix?

$
0
0
This is the implementation. Is there any way to avoid the casting?
 public static Matrix<T> AddVectorOnEachColumn<T>(this Matrix<T> m1, Vector<T> v, T scale) where T : struct, 
                                                                                                     IEquatable<T>, IFormattable
 {
     Contract.Requires(m1 != null);
     Contract.Requires(v != null);
 
     if (m1 is Matrix<float>)
     {
         var fm1 = m1 as Matrix<float>;
         var fv = v as Vector<float>;
         var fscale = (float)(object)scale;
 
         return fm1.MapIndexed((i, j, value) => fm1.At(i, j) + fscale * fv.At(j)) as Matrix<T>;
     }
     else if (m1 is Matrix<double>)
     {
         var dm1 = m1 as Matrix<double>;
         var dv = v as Vector<double>;
         var dscale = (double)(object)scale;
 
         return dm1.MapIndexed((i, j, value) => dm1.At(i, j) + dscale * dv.At(j)) as Matrix<T>;
     }
     else throw new NotSupportedException("Type: {0} is not supported by the Matrix<T> class.");
 }

New Post: How to apply operation over vector from each row/column of a matrix?

$
0
0
dm1.At(i, j) is already provided as value:
fm1.MapIndexed((i, j, value) => value + fscale * fv.At(j)) as Matrix<T>
Then you can pre-scale the vector, once, which is supported generically; getting rid of some of the casting:
var fm1 = m1 as Matrix<float>;
var fsv = (v * scale) as Vector<float>;
return fm1.MapIndexed((i, j, value) => value + fsv.At(j)) as Matrix<T>;
Do you actually need the extension function to be generic? If not, you can just overload per type individually, without any casting:
// Inplace:
public static void AddScaledVectorToEachColumnInplace(this Matrix<double> m, Vector<double> v, double scale)
{
    double[] scaled = (v * scale).ToArray();
    m.MapIndexedInplace((i,j,x) => x + scaled[i], Zeros.Include);
}
public static void AddScaledVectorToEachColumnInplace(this Matrix<float> m, Vector<float> v, float scale)
{
    float[] scaled = (v * scale).ToArray();
    m.MapIndexedInplace((i,j,x) => x + scaled[i], Zeros.Include);
}

// Outplace:
public static Matrix<double> AddScaledVectorToEachColumn(this Matrix<double> m, Vector<double> v, double scale)
{
    double[] scaled = (v * scale).ToArray();
    return m.MapIndexed((i,j,x) => x + scaled[i], Zeros.Include);
}

New Post: Step function/interpolator

$
0
0
Christoph,

I am not sure if you saw my alternative implementation of LeftBracketIndex which uses Array.BinarySearch. I'd recommend adopting it at other places.

Candy

New Post: Sparse matrix performance

$
0
0
Thanks again. I've included the change and extended it to the writer as well. Since dense matrices are stored in column-major format it was possible to optimize the dense case slightly as well, along the same lines. Available in the MathNet.Numerics.Data.Matlab v3.0.0 package.

Thanks,
Christoph
Viewing all 971 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>