tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

sparse_linear_solver.h (2587B)


      1 /*
      2 * Copyright (c) 2021, Alliance for Open Media. All rights reserved.
      3 *
      4 * This source code is subject to the terms of the BSD 2 Clause License and
      5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
      6 * was not distributed with this source code in the LICENSE file, you can
      7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
      8 * Media Patent License 1.0 was not distributed with this source code in the
      9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
     10 */
     11 
     12 #ifndef AOM_AV1_ENCODER_SPARSE_LINEAR_SOLVER_H_
     13 #define AOM_AV1_ENCODER_SPARSE_LINEAR_SOLVER_H_
     14 
     15 #ifdef __cplusplus
     16 extern "C" {
     17 #endif
     18 
     19 #include "config/aom_config.h"
     20 
     21 #if CONFIG_OPTICAL_FLOW_API
     22 
     23 // Number of iterations for solving linear equations.
     24 #define MAX_CG_SP_ITER 100
     25 
     26 typedef struct {
     27  int n_elem;  // number of non-zero elements
     28  int n_rows;
     29  int n_cols;
     30  // using arrays to represent non-zero elements.
     31  int *col_pos;
     32  int *row_pos;  // starts with 0
     33  double *value;
     34 } SPARSE_MTX;
     35 
     36 int av1_init_sparse_mtx(const int *rows, const int *cols, const double *values,
     37                        int num_elem, int num_rows, int num_cols,
     38                        SPARSE_MTX *sm);
     39 int av1_init_combine_sparse_mtx(const SPARSE_MTX *sm1, const SPARSE_MTX *sm2,
     40                                SPARSE_MTX *sm, int row_offset1,
     41                                int col_offset1, int row_offset2,
     42                                int col_offset2, int new_n_rows,
     43                                int new_n_cols);
     44 void av1_free_sparse_mtx_elems(SPARSE_MTX *sm);
     45 
     46 void av1_mtx_vect_multi_right(const SPARSE_MTX *sm, const double *srcv,
     47                              double *dstv, int dstl);
     48 void av1_mtx_vect_multi_left(const SPARSE_MTX *sm, const double *srcv,
     49                             double *dstv, int dstl);
     50 double av1_vect_vect_multi(const double *src1, int src1l, const double *src2);
     51 void av1_constant_multiply_sparse_matrix(SPARSE_MTX *sm, double c);
     52 
     53 int av1_conjugate_gradient_sparse(const SPARSE_MTX *A, const double *b, int bl,
     54                                  double *x);
     55 int av1_bi_conjugate_gradient_sparse(const SPARSE_MTX *A, const double *b,
     56                                     int bl, double *x);
     57 int av1_jacobi_sparse(const SPARSE_MTX *A, const double *b, int bl, double *x);
     58 int av1_steepest_descent_sparse(const SPARSE_MTX *A, const double *b, int bl,
     59                                double *x);
     60 
     61 #endif  // CONFIG_OPTICAL_FLOW_API
     62 
     63 #ifdef __cplusplus
     64 }  // extern "C"
     65 #endif
     66 
     67 #endif /* AOM_AV1_ENCODER_SPARSE_LINEAR_SOLVER_H_ */