def test_lesq_solution2():
    # Exactly constrained.
    N = np.array([22, 23, 34])
    DE = np.matrix([[1, 0, 0], [0, 1, 0], [1, 1, 1]])
    b_true = np.array([1.234, 1.456, 1.789])
    dd_obs = bl.predict_carrier_obs_(N, DE, b_true)
    code, b, resid = bl.lesq_solution_float_(dd_obs, N, DE)
    assert code == 0
    assert np.allclose(b, b_true)
def test_lesq_solution2():
  # Exactly constrained.
  N = np.array([22, 23, 34])
  DE = np.matrix([[1, 0, 0],
                  [0, 1, 0],
                  [1, 1, 1]])
  b_true = np.array([1.234, 1.456, 1.789])
  dd_obs = bl.predict_carrier_obs_(N, DE, b_true)
  code, b, resid = bl.lesq_solution_float_(dd_obs, N, DE)
  assert code == 0
  assert np.allclose(b, b_true)
def test_lesq_solution5():
    # Over constrained with non-zero residuals
    N = np.array([0, 0, 0, 0])
    DE = np.matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 0, 0]])
    b_true = np.array([0, 0, 0])
    dd_obs = np.array([0, 0, 0, 1])
    code, b, resid = bl.lesq_solution_float_(dd_obs, N, DE)
    b_expected = np.array([0.5 * c.GPS_L1_LAMBDA_NO_VAC_, 0, 0])
    resid_expected = np.array([-0.5, 0, 0, 0.5])
    assert code == 0, "solution returned error %d" % code
    np.allclose(b, b_true)
    np.allclose(resid, resid_expected)
def test_lesq_solution5():
  # Over constrained with non-zero residuals
  N = np.array([0, 0, 0, 0])
  DE = np.matrix([[1, 0, 0],
                  [0, 1, 0],
                  [0, 0, 1],
                  [1, 0, 0]])
  b_true = np.array([0, 0, 0])
  dd_obs = np.array([0, 0, 0, 1])
  code, b, resid = bl.lesq_solution_float_(dd_obs, N, DE)
  b_expected = np.array([0.5*c.GPS_L1_LAMBDA_NO_VAC_, 0, 0])
  resid_expected = np.array([-0.5, 0, 0, 0.5])
  assert code == 0, "solution returned error %d" % code
  np.allclose(b, b_true)
  np.allclose(resid, resid_expected)