Evaluating expressions consisting of elementwise matrix operations in Thrust

I would like to use Thrust to evaluate expressions consisting of elementwise matrix operations. To make it clear, let us consider an expression like:


where A, B, C and D are matrices, of course of the same size.

The Thrust Quick Start Guide provides the saxpy example for which y is used both as input and as output, while in my case the output argument is different from the input ones which, by the way, are more than two. At Element-by-element vector multiplication with CUDA, the case of output different than the input, but of only two inputs, is considered.

Could anyone provide some suggestions (and possibly the rationale behind) on how using Thrust to implement the expression above (output matrix different from the inputs and more than two inputs)?

This topic has been discussed at