public virtual void linearTest()
        {
            bool print = false;

            if (print)
            {
                Console.WriteLine("NonLinearLeastSquareWithPenaltyTest.linearTest");
            }
            int          nWeights  = 20;
            int          diffOrder = 2;
            double       lambda    = 100.0;
            DoubleMatrix penalty   = (DoubleMatrix)MA.scale(getPenaltyMatrix(nWeights, diffOrder), lambda);

            int[]    onIndex = new int[] { 1, 4, 11, 12, 15, 17 };
            double[] obs     = new double[] { 0, 1.0, 1.0, 1.0, 0.0, 0.0 };
            int      n       = onIndex.Length;

            System.Func <DoubleArray, DoubleArray> func = (DoubleArray x) =>
            {
                return(DoubleArray.of(n, i => x.get(onIndex[i])));
            };

            System.Func <DoubleArray, DoubleMatrix> jac = (DoubleArray x) =>
            {
                return(DoubleMatrix.of(n, nWeights, (i, j) => j == onIndex[i] ? 1d : 0d));
            };

            Well44497b  random = new Well44497b(0L);
            DoubleArray start  = DoubleArray.of(nWeights, i => random.NextDouble());

            LeastSquareWithPenaltyResults lsRes = NLLSWP.solve(DoubleArray.copyOf(obs), DoubleArray.filled(n, 0.01), func, jac, start, penalty);

            if (print)
            {
                Console.WriteLine("chi2: " + lsRes.ChiSq);
                Console.WriteLine(lsRes.FitParameters);
            }
            for (int i = 0; i < n; i++)
            {
                assertEquals(obs[i], lsRes.FitParameters.get(onIndex[i]), 0.01);
            }
            double expPen = 20.87912357454752;

            assertEquals(expPen, lsRes.Penalty, 1e-9);
        }