# What is the correct way of using LinearCG?

**URL:** <https://community.freefem.org/t/what-is-the-correct-way-of-using-linearcg/3744>\
**Category:** General Discussion\
**Created:** [February 12, 2025, 10:04am UTC](https://community.freefem.org/t/what-is-the-correct-way-of-using-linearcg/3744 "2025-02-12T10:04:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![oldoldman](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/oldoldman/32/2725_2.png) [@oldoldman](https://community.freefem.org/u/oldoldman)\
**Post date:** [February 12, 2025, 10:04am UTC](https://community.freefem.org/t/what-is-the-correct-way-of-using-linearcg/3744/1 "2025-02-12T10:04:55Z")

</div>

Hi guys,  
I’m trying to understand LinearCG by the following script

```auto
func real[int] A(real[int] i) {
  real[int] a= [1,2,3,4];
  return a;
}
real[int] x(2);
real[int] B=[2,3];
LinearCG(A,x,B);
cout << x << endl;

```

In my understanding, this will solve the linear equation

```auto
Ax=B

```

the result will be in `x`, but I got the following error

```auto
Exec error : CG2: Matrix is not defined (/0), sorry

```

Any suggestion? Many thanks!

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [February 12, 2025, 10:47am UTC](https://community.freefem.org/t/what-is-the-correct-way-of-using-linearcg/3744/2 "2025-02-12T10:47:29Z")

</div>

Your operator is not linear, it is constant, thus CG fails.
