Does anyone know how does blender casts a RGB color to a one dimensional value? Does it first compute the amplitude of the color vector and then passes that as the factor, or does it apply color ramp per component of the input vector?
It uses the "luminance" of the color, from a HSL model, which is a generally-agreed upon representation of the perceptual brightness of color. The luminance weighs the green channel more highly than the blue channel. You can, of course, do any math you want on your color to cast it to a factor in whatever way you'd like.