Add mju_mulVecMatVec, mutiplies a square matrix M by a vector x on both sides. Returns x^T * M * x.
PiperOrigin-RevId: 474292806 Change-Id: I3432469dbe1f02ccf5a13241c7aa12d824cbe034
This commit is contained in:
committed by
Copybara-Service
parent
ee9eccc992
commit
f4e7fa97af
@@ -190,7 +190,7 @@ static void residual(const mjModel* m, mjData* d, mjtNum* res, int i, int dim, i
|
||||
// compute cost change
|
||||
static mjtNum costChange(const mjtNum* A, mjtNum* force, const mjtNum* oldforce,
|
||||
const mjtNum* res, int dim) {
|
||||
mjtNum delta[6], v[6], change;
|
||||
mjtNum delta[6], change;
|
||||
|
||||
// compute change
|
||||
if (dim==1) {
|
||||
@@ -198,8 +198,7 @@ static mjtNum costChange(const mjtNum* A, mjtNum* force, const mjtNum* oldforce,
|
||||
change = 0.5*delta[0]*delta[0]*A[0] + delta[0]*res[0];
|
||||
} else {
|
||||
mju_sub(delta, force, oldforce, dim);
|
||||
mju_mulMatVec(v, A, delta, dim, dim);
|
||||
change = 0.5*mju_dot(delta, v, dim) + mju_dot(delta, res, dim);
|
||||
change = 0.5*mju_mulVecMatVec(delta, A, delta, dim) + mju_dot(delta, res, dim);
|
||||
}
|
||||
|
||||
// positive change: restore
|
||||
|
||||
Reference in New Issue
Block a user