Generating ColorMatrix1 from input data

I have an application where we take in a RAW file, apply some processing, and then output to a DNG via libtiff. I get almost all the information I need to generate the DNG file out of libraw fine, but I cannot find out where or how ColorMatrix1 is generated. It seems like cam_xyz is always ColorMatrix2, and rgb_cam is an interpolation of ColorMatrix1 and 2, but I don't know how to work my way to ColorMatrix1 for arbitrary input. Is this something that can be accomplished with libraw?

Forums: 

I'm having the same problem,

I'm having the same problem, Have you found any solution that you can share?