Spec-Zone.ru › Octave 9

21.4 Примеры использования

Следующее можно использовать для решения линейной системы A*x = b с помощью LU-разложения с выбором главного элемента:

[L, U, P] = lu (A); ## now L*U = P*A
  x = U \ (L \ P) * b;

Так можно нормализовать столбцы матрицы X до единичной нормы:

s = norm (X, "columns");
  X /= diag (s);

То же самое можно сделать с помощью broadcasting (см. раздел Broadcasting):

s = norm (X, "columns");
  X ./= s;

Следующее выражение позволяет эффективно вычислить знак перестановки, заданной вектором перестановки p. Оно будет работать и в более ранних версиях Octave, но медленно.

det (eye (length (p))(p, :))

Наконец, вот как решить линейную систему A*x = b с помощью регуляризации Тихонова (гребневой регрессии) и SVD (только схема):

m = rows (A); n = columns (A);
  [U, S, V] = svd (A);
  ## determine the regularization factor alpha
  ## alpha = ...
  ## transform to orthogonal basis
  b = U'*b;
  ## Use the standard formula, replacing A with S.
  ## S is diagonal, so the following will be very fast and accurate.
  x = (S'*S + alpha^2 * eye (n)) \ (S' * b);
  ## transform to solution basis
  x = V*x;

© 1996–2026 The Octave Project Developers
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.
https://docs.octave.org/v9.4.0/Example-Code.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API