how to create matrix of complex number when matrix.init only accept float?

Answered how to create matrix of complex number when matrix.init only accept float?

  • Tuesday, May 01, 2012 6:00 AM
     
     

    How to create matrix of complex number?

    let A = new Matrix<Complex>(m, n)

    let A = new Matrix<Complex>(m, n, (fun x y -> complex 0.0 0.0))

    both way are wrong


    我要呢個女人賠醫藥費, 支持呢個女人的人們和她男友Nelson, 我買佢地跑草地獨贏




    • Edited by 沈世鈞 Tuesday, May 01, 2012 9:16 AM
    • Edited by 沈世鈞 Tuesday, May 01, 2012 9:34 AM
    • Edited by 沈世鈞 Tuesday, May 01, 2012 11:01 AM
    •  

All Replies

  • Tuesday, May 01, 2012 1:28 PM
     
     Answered Has Code

    I assume you are using Microsoft.FSharp.Math.

    In this case you have to use 'init' function from Matrix.Generic module:

    let matrix1 = Matrix.Generic.init 3 3 (fun i j -> complex 1.0 0.0)
    
    > 
    
    val matrix1 : Matrix<complex> = matrix [[1r+0i; 1r+0i; 1r+0i]
                                            [1r+0i; 1r+0i; 1r+0i]
                                            [1r+0i; 1r+0i; 1r+0i]]


    Petr

    • Marked As Answer by 沈世鈞 Thursday, May 03, 2012 4:06 AM
    •  
  • Thursday, May 03, 2012 4:07 AM
     
     Proposed Answer

    very useful


    can change program to Logic and change back to program and compile to run and show result in the same Console

    • Proposed As Answer by jjag0540 Thursday, May 03, 2012 8:19 AM
    •