locked
How to convert Variable<Vector> to VariableArray<double>? (Migrated from community.research.microsoft.com) RRS feed

  • Question

  • bcao posted on 07-28-2010 3:53 PM

    Thanks!

    Friday, June 3, 2011 6:13 PM

Answers

  • minka replied on 01-14-2011 9:45 AM

    In version 2.4, there is now a simpler and more efficient way to do this, using Variable.ArrayFromVector.  You can go the other direction using Variable.Vector(array).

    Friday, June 3, 2011 6:14 PM

All replies

  • John Guiver replied on 07-29-2010 11:20 AM

    Here's an example. Let me know if you need further help.

    John

    int dim = 5;
    int[] indices = Enumerable.Range(0, dim).ToArray();

    Variable<Vector> v = Variable.VectorGaussianFromMeanAndPrecision(new Vector(dim), PositiveDefiniteMatrix.Identity(dim));
    Range r = new Range(dim);
    var indVar = Variable.Observed<int>(indices, r);
    var va = Variable.Array<double>(r);
    va[r] = Variable.GetItem(v, indVar[r]);

    Friday, June 3, 2011 6:14 PM
  • bcao replied on 07-29-2010 2:11 PM

    Thank you very much for your help!

    Friday, June 3, 2011 6:14 PM
  • minka replied on 01-14-2011 9:45 AM

    In version 2.4, there is now a simpler and more efficient way to do this, using Variable.ArrayFromVector.  You can go the other direction using Variable.Vector(array).

    Friday, June 3, 2011 6:14 PM