1+ /*
2+ * @Author: Zhou Yanyu(周妍妤) 47125824+Yanyu000@users.noreply.github.com
3+ * @Date: 2025-07-14 12:06:25
4+ * @LastEditors: Zhou Yanyu(周妍妤) 47125824+Yanyu000@users.noreply.github.com
5+ * @LastEditTime: 2025-08-05 14:47:53
6+ * @FilePath: /cupdlp-CPP/include/linalg.hpp
7+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
8+ */
9+ #ifndef LINALG_HPP
10+ #define LINALG_HPP
11+
12+ #include < vector>
13+ #include " Highs.h"
14+
15+ namespace linalg {
16+ double project_box (double x, double l, double u);
17+ double project_non_negative (double y);
18+
19+ // Function to compute A*x for a given HighsLp and vector x
20+ void Ax (const HighsLp &lp, const std::vector<double > &x, std::vector<double > &result);
21+
22+ // Function to compute A^T*y for a given HighsLp and vector y
23+ void ATy (const HighsLp &lp, const std::vector<double > &y, std::vector<double > &result);
24+
25+ double nrm2 (const std::vector<double >& vec);
26+ void scale (std::vector<double >& vec, double factor);
27+
28+ void normalize (std::vector<double >& vec);
29+
30+ double dot (const std::vector<double >& a, const std::vector<double >& b);
31+
32+ double diffTwoNorm (const std::vector<double >& v1, const std::vector<double >& v2);
33+
34+ // General norm functions
35+ double vector_norm (const std::vector<double >& vec, double p = 2.0 );
36+ double vector_norm (const double * values, size_t size, double p = 2.0 );
37+
38+ // LP-specific norm calculations
39+ double compute_cost_norm (const HighsLp& lp, double p = 2.0 );
40+ double compute_rhs_norm (const HighsLp& lp, double p = 2.0 );
41+
42+ // Matrix column/row norm calculations
43+ std::vector<double > compute_column_norms (const HighsLp& lp, double p = std::numeric_limits<double >::infinity());
44+ std::vector<double > compute_row_norms (const HighsLp& lp, double p = std::numeric_limits<double >::infinity());
45+ } // namespace linalg
46+
47+ #endif // LINALG_HPP
0 commit comments