简体   繁体   English

C# Mathnet Numerics Polynomial Evaluate 跨向量/数组,我必须循环吗?

[英]C# Mathnet Numerics Polynomial Evaluate across an vector/array, do I have to loop?

Ok, so I'm attempting to fumble my way through a Matlab source code conversion into C#.好的,所以我试图通过将 Matlab 源代码转换为 C# 来摸索。 Thus far I've been able to do everything without needing to implement any loops.到目前为止,我已经能够在不需要实现任何循环的情况下完成所有工作。

data = vector of data Fourier.Forward(data.AsArray()) takes in data and overwrites the original vector with the results. data = 数据向量 Fourier.Forward(data.AsArray()) 接收数据并用结果覆盖原始向量。 Vector.ABS(data) calculates the absolute value across the vector Polynomial.Fit(x.AsArray(), data.Array()) calculates and returns the coefficients for the polynomial Vector.ABS(data) 计算向量的绝对值 Polynomial.Fit(x.AsArray(), data.Array()) 计算并返回多项式的系数

but now I need to plot and find the Y value based on the X. The only function I can find is但现在我需要根据 X 绘制并找到 Y 值。我能找到的唯一函数是

Polynomial.Evaluate, but it takes in a single X value, and returns the Y. Is there a function that will take in my entire vector or as an array, that will return a single vector/array of results? Polynomial.Evaluate,但它接受单个 X 值,并返回 Y。是否有一个函数可以接受我的整个向量或作为数组,返回单个向量/结果数组?

You can use Linq's Select.您可以使用 Linq 的 Select。

If you have a collection of X in xCol, and Polynomial.Evaluate evaluates an X into a Y, you can do the following:如果 xCol 中有 X 的集合,并且Polynomial.Evaluate将 X 计算为 Y,则可以执行以下操作:

var yCol = xCol.Select(x => Polynomial.Evaluate(x)).

It's effectively a loop, but it looks and acts like a vector function它实际上是一个循环,但它的外观和行为就像一个向量函数

The way it works is that the lamba you specified它的工作方式是您指定的lamba

x => Polynomial.Evaluate(x)

Is applied to each member of xCol , resulting in an output enumerable collection.应用于xCol每个成员,从而产生一个输出可枚举集合。

You can read that lambda as "given an x, return Polynomial.Evaluate(x)"你可以把那个 lambda 读作“给定一个 x,返回 Polynomial.Evaluate(x)”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以将 MathNet 数字库中的矩阵更改为数组吗? - Can I change a matrix in MathNet Numerics Library to an array? 在MathNet.Numerics命名空间中查询向量的长度 - Query length of a vector in MathNet.Numerics namespace 我在MathNet.Numerics中的傅里叶变换(卷积)有什么问题? - C# - What is wrong with my Fourier Transformation (Convolution) in MathNet.Numerics? - C# 如何使用MathNet数值获取特征值作为按大小顺序列出的向量? - How to get eigenvalues as a Vector listed in order of magnitude using MathNet Numerics? 如何使用MathNET.Numerics获得矢量幅度? - How to get vector magnitude using MathNET.Numerics? MathNet.Numerics.LinearAlgebra:如何快速将Vector附加到另一个Vector? - MathNet.Numerics.LinearAlgebra: how to append a Vector to another quickly? C# Matrix*Vector = DotProduct 使用 MathNet 库 - C# Matrix*Vector = DotProduct Using MathNet Library C# .Net SIMD System.Numerics.Vector4 比循环慢 - C# .Net SIMD System.Numerics.Vector4 slower than loop 指向包含System.Numerics.Vector的struct的指针 <double> 在C#中 - Pointer to struct containing System.Numerics.Vector<double> in C# 如何在C#中获取System.Numerics.Vector的元素? - How to get the elements of a System.Numerics.Vector in C#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM