public void InPlaceApply(
Func<double, double> func
)
Public Sub InPlaceApply (
func As Func(Of Double, Double)
)
public:
void InPlaceApply(
Func<double, double>^ func
)
member InPlaceApply :
func : Func<float, float> -> unit
Let be a matrix, and consider its generic entry
where and
are the
number of rows and columns of
, respectively.
Let the function represented by
func.
Then method InPlaceApply(Func<Double, Double>) transforms
by setting
In the following example, the entries in a matrix are all squared.
using System;
namespace Novacta.Analytics.CodeExamples
{
public class InPlaceApplyExample0
{
public void Main()
{
// Create a matrix.
var data = new double[20] {
1, 8, -3, 6, -2,
2, 2, 2, 0, 7,
-3, 9, 3, 2, 9,
5, 2, -5, -1, -4
};
var matrix = DoubleMatrix.Dense(4, 5, data, StorageOrder.RowMajor);
Console.WriteLine("Initial data matrix:");
Console.WriteLine(matrix);
// Square all matrix entries.
matrix.InPlaceApply((x) => Math.Pow(x, 2.0));
Console.WriteLine();
Console.WriteLine("Matrix transformed by squaring its entries:");
Console.WriteLine(matrix);
}
}
}
// Executing method Main() produces the following output:
//
// Initial data matrix:
// 1 8 -3 6 -2
// 2 2 2 0 7
// -3 9 3 2 9
// 5 2 -5 -1 -4
//
//
//
// Matrix transformed by squaring its entries:
// 1 64 9 36 4
// 4 4 4 0 49
// 9 81 9 4 81
// 25 4 25 1 16
//
//
ArgumentNullException | func is null. |