Constrained least-squares analysis of petrologic problems with an application to lunar sample 12040