Apparently, both matrix inverse and product is implemented in Stan, so perhaps I don't need an external function after all.
Perhaps it was not entirely clear from my first explanation, so let me add a bit more detail on what I'm dealing with. With my current model, my likelihood function depends on three parameters: LikelihoodF(x | param1, param2, param3). I have no analytical expression for the likelihood function as you do for the Triangle in chapter 21. The relevant range of x values is perhaps [20.0 ; 40.0]. Using some linear algebra, I can calculate the probability density function over a discretized space of x's (for instance 20.0, 20.1, 20.2 ... 40.0) for a given set of (param1, param2, param3). If the observed x's can be rounded (and they can) to the nearest 0.1 decimal, I would perhaps not have to interpolate.
Hope it makes somes sense. I'm quite new to stan.