Код: Выделить всё
#include
#include
#include
#include
#include /* pair */
#include
#include
using namespace std;
void print_gslmat (const gsl_matrix* m);
void print_gslvec (const gsl_vector* v);
int main()
{
gsl_matrix* final_results_mat = gsl_matrix_calloc (6, 4); /* creates a matrix of size n1 rows by n2 columns, returning a pointer to a newly initialized matrix */
double ar[] = {4141, 448, 9.2, 0.00025,
3362, 297, 11.3, 0.00009,
-2712, 297, 9.1, 0.00026,
-2123, 388, 5.47, 0.00279,
684.5, 289, 2.37, 0.0642,
1034, 289, 3.588, 0.0159,
};
for (size_t i = 0; i < 6; i++)
{
for (size_t j = 0; j < 4; j++)
{
gsl_matrix_set (final_results_mat, i, j, ar[i * 4 + j]);
// sets the value of the (i,j)-th element of a matrix m
}
}
// print_gslmat (final_results_mat);
vector svec = {"x0", "x1", "x2", "x1x2", "x1x1", "x2x2"};
gsl_vector* temp_vec_1 = gsl_vector_calloc (4); // work for temp_vec_1
// gsl_vector* temp_vec_2 = gsl_vector_calloc (5); //
Попытка бесплатно вектор temp_vec_2 (№ 1). 3,588000 0,015900
x1 0,000000 0,000000 289,000000 3,588000 0,015900
x2 0,000000 0,000000 289,000000 3,588000 0,015900
x1x2 0,00000000000000 289,000000 3,588000 0,015900
x2x2 0,000000 0,000000 289,000000 3.588000 0,015900
< /pre>
Что я делаю не так?
Спасибо, читатели, за ваше внимание. < /P.>
Подробнее здесь: [url]https://stackoverflow.com/questions/79760375/where-in-the-program-should-i-free-a-previously-allocated-vector-from-the-gsl-li[/url]