/*
 * This file is part of QDLDL, a library for performing the LDL^T factorization
 * of a symmetric indefinite matrix.
 *
 * QDLDL is part of the OSQP project, and is available at https://github.com/osqp/qdldl.
 *
 * Copyright 2018, Paul Goulart, The OSQP developers
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

static char* test_singleton() {
    // A matrix data
    QDLDL_int   Ap[] = { 0, 1 };
    QDLDL_int   Ai[] = { 0 };
    QDLDL_float Ax[] = { 0.2 };
    QDLDL_int   An = 1;

    // RHS and solution to Ax = b
    QDLDL_float b[] = { 2 };
    QDLDL_float xsol[] = { 10.0 };

    // x replaces b during solve
    int status = ldl_factor_solve(An, Ap, Ai, Ax, b);

    mu_assert("Factorisation failed", status >= 0);
    mu_assert("Solve accuracy failed", vec_diff_norm(b, xsol, An) < QDLDL_TESTS_TOL);

    return 0;
}
