May block() be used to write values?

10 views
Skip to first unread message

terrance savitsky

unread,
May 16, 2016, 12:13:59 PM5/16/16
to stan-...@googlegroups.com
Hi, I'm writing a function to create a block-diagonal matrix.   May one use block() to write values to a sub-block of a matrix?

Thank you,

Terrance

--
Thank you, Terrance Savitsky

Jonah Gabry

unread,
May 16, 2016, 1:29:25 PM5/16/16
to Stan users mailing list
Hi Terrance, 

We don't have R-style replacement functions (not sure if that's on Bob's long-term to-do list for the language or not), so you can't do something like 

block(A, ...) <- B;

However, recent versions of Stan do allow for much more flexibility with indexing (including for assignment), so I think you should be able to do things like 

A[i:j, k:l] <- B; // i,j,k,l integers
A
[row_ids, col_ids] <- B; //row_ids, col_ids integer arrays

that weren't previously possible. Hope that helps, 

Jonah

terrance savitsky

unread,
May 16, 2016, 1:46:54 PM5/16/16
to stan-...@googlegroups.com
Hi Jonah,  This is just what I needed.  Thanks for your help.   Terrance.

--
You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
To post to this group, send email to stan-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages