Home | History | Annotate | Download | only in ceres
      1 // Ceres Solver - A fast non-linear least squares minimizer
      2 // Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
      3 // http://code.google.com/p/ceres-solver/
      4 //
      5 // Redistribution and use in source and binary forms, with or without
      6 // modification, are permitted provided that the following conditions are met:
      7 //
      8 // * Redistributions of source code must retain the above copyright notice,
      9 //   this list of conditions and the following disclaimer.
     10 // * Redistributions in binary form must reproduce the above copyright notice,
     11 //   this list of conditions and the following disclaimer in the documentation
     12 //   and/or other materials provided with the distribution.
     13 // * Neither the name of Google Inc. nor the names of its contributors may be
     14 //   used to endorse or promote products derived from this software without
     15 //   specific prior written permission.
     16 //
     17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
     21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     26 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27 // POSSIBILITY OF SUCH DAMAGE.
     28 //
     29 // Author: keir (a] google.com (Keir Mierle)
     30 
     31 syntax = "proto2";
     32 
     33 package ceres.internal;
     34 
     35 message BlockProto {
     36   // The span of the block.
     37   optional int32 size = 1;
     38 
     39   // Position along the row or column (depending on storage orientation).
     40   optional int32 position = 2;
     41 }
     42 
     43 message CellProto {
     44   // Column or row block id as appropriate.
     45   optional int32 block_id = 1;
     46 
     47   // Position in the values array the cell is located. Each cell is stored as a
     48   // row-major chunk inside the values array.
     49   optional int32 position = 2;
     50 }
     51 
     52 // A single row or column, depending on the matrix type.
     53 message CompressedRowProto {
     54   optional BlockProto block = 2;
     55   repeated CellProto cells = 1;
     56 }
     57 
     58 message BlockStructureProto {
     59   repeated BlockProto cols = 1;
     60   repeated CompressedRowProto rows = 2;
     61 }
     62 
     63 // A block sparse matrix, either in column major or row major format.
     64 message BlockSparseMatrixProto {
     65   optional int64 num_rows = 2;
     66   optional int64 num_cols = 3;
     67   optional int64 num_nonzeros = 4;
     68   repeated double values = 1 [packed=true];
     69 
     70   optional BlockStructureProto block_structure = 5;
     71 }
     72 
     73 message TripletSparseMatrixProto {
     74   optional int64 num_rows = 4;
     75   optional int64 num_cols = 5;
     76   optional int64 num_nonzeros = 6;
     77 
     78   // The data is stored as three arrays. For each i, values(i) is stored at the
     79   // location (rows(i), cols(i)). If the there are multiple entries with the
     80   // same (rows(i), cols(i)), the values entries corresponding to them are
     81   // summed up.
     82   repeated int64 rows = 1 [packed=true];
     83   repeated int64 cols = 2 [packed=true];
     84   repeated double values = 3 [packed=true];
     85 }
     86 
     87 message CompressedRowSparseMatrixProto {
     88   optional int64 num_rows = 4;
     89   optional int64 num_cols = 5;
     90 
     91   repeated int64 rows = 1 [packed=true];
     92   repeated int64 cols = 2 [packed=true];
     93   repeated double values = 3 [packed=true];
     94 }
     95 
     96 message DenseSparseMatrixProto {
     97   optional int64 num_rows = 1;
     98   optional int64 num_cols = 2;
     99 
    100   // Entries are stored in row-major order.
    101   repeated double values = 3 [packed=true];
    102 }
    103 
    104 // A sparse matrix. It is a union; only one field is permitted. If new sparse
    105 // implementations are added, update this proto accordingly.
    106 message SparseMatrixProto {
    107   optional TripletSparseMatrixProto triplet_matrix = 1;
    108   optional BlockSparseMatrixProto block_matrix = 2;
    109   optional CompressedRowSparseMatrixProto compressed_row_matrix = 3;
    110   optional DenseSparseMatrixProto dense_matrix = 4;
    111 }
    112 
    113 // A linear least squares problem.
    114 //
    115 // Given a matrix A, an optional diagonal matrix D as a vector, and a vector b,
    116 // the proto represents the following linear least squares problem.
    117 //
    118 //   | A | x = | b |
    119 //   | D |     | 0 |
    120 //
    121 // If D is empty, then the problem is considered to be
    122 //
    123 //   A x = b
    124 //
    125 // The desired solution for the problem is the vector x that solves the
    126 // following optimization problem:
    127 //
    128 //   arg min_x ||Ax - b||^2 + ||Dx||^2
    129 //
    130 // If x is present, then it is the expected solution to the
    131 // problem. The dimensions of A, b, x, and D should be consistent.
    132 message LinearLeastSquaresProblemProto {
    133   optional SparseMatrixProto a = 1;
    134   repeated double b = 2 [packed=true];
    135   repeated double d = 3 [packed=true];
    136   repeated double x = 4 [packed=true];
    137   // If the problem is of SfM type, i.e it has a generalized
    138   // bi-partite structure, then num_eliminate_blocks is the number of
    139   // column blocks that are to eliminated in the formation of the
    140   // Schur complement. For more details see
    141   // explicit_schur_complement_solver.h.
    142   optional int32 num_eliminate_blocks = 5;
    143 }
    144