简体   繁体   English

F#:如何打印矩阵?

[英]F#: How to print a matrix?

I'm using Math.Net and trying to create a matrix with a random Gaussian distribution. 我正在使用Math.Net并尝试创建具有随机高斯分布的矩阵。 Then I trying to print the matrix but can't: 然后我尝试打印矩阵,但不能:

Successive arguments should be separated by spaces or tupled, and arguments involving function or method applications should be parenthesized 连续的参数应以空格或元组分隔,涉及函数或方法应用程序的参数应加括号

What I'm doing wrong? 我做错了什么? Taking a look at examples is misleading me much more. 一些例子更容易误导我。

  printfn "%s" (DenseMatrix.random<float> 1000 50 (Normal(1.0, 100.0))).ToString()

When the error message says "arguments involving function or method applications should be parenthesized", what that means is that this: 当错误消息显示“应将涉及函数或方法应用程序的参数括起来”时,这意味着:

printfn "%s" foo.ToString()

needs to be written as: 需要写成:

printfn "%s" (foo.ToString())

So put an extra set of parentheses around your DenseMatrix value and it should work: 因此,在您的DenseMatrix值周围放上一组括号,它应该可以工作:

printfn "%s" ((DenseMatrix.random<float> 1000 50 (Normal(1.0, 100.0))).ToString())

The reason for this language design choice gets into advanced topics like currying which you probably don't care about right now, so I'll spare you the long explanation. 选择这种语言的原因是涉及诸如currying之类的高级主题,您现在可能并不在意这些主题,因此,我将省去冗长的解释。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM