MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RTOp_SparseSubVector.c
Go to the documentation of this file.
1 /*
2 // @HEADER
3 // ***********************************************************************
4 //
5 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
6 // Copyright (2003) Sandia Corporation
7 //
8 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9 // license for use of this work by or on behalf of the U.S. Government.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
39 //
40 // ***********************************************************************
41 // @HEADER
42 */
43 
44 #include "RTOp_SparseSubVector.h"
45 
47  RTOp_index_type global_offset, RTOp_index_type sub_dim
48  ,RTOp_index_type sub_nz, const RTOp_value_type values[], ptrdiff_t values_stride
49  ,const RTOp_index_type indices[], ptrdiff_t indices_stride
50  ,ptrdiff_t local_offset, int is_sorted
51  ,struct RTOp_SparseSubVector *sub_vec
52  )
53 {
54  /* Validate input */
55 #ifdef RTOp_DEBUG
56  assert( sub_vec );
57  assert(
58  ( sub_nz && ( values != NULL && indices != NULL && indices_stride != 0 && sub_nz <= sub_dim ) )
59  || !sub_nz || ( sub_nz == sub_dim && indices == NULL )
60  );
61 #endif
62  /* Set members */
63  sub_vec->global_offset = global_offset;
64  sub_vec->sub_dim = sub_dim;
65  sub_vec->sub_nz = sub_nz;
66  sub_vec->values = values;
67  sub_vec->values_stride = values_stride;
68  sub_vec->indices = indices;
69  sub_vec->indices_stride = indices_stride;
70  sub_vec->local_offset = local_offset;
71  sub_vec->is_sorted = is_sorted;
72 }
73 
75 {
76  sub_vec->global_offset = 0;
77  sub_vec->sub_dim = 0;
78  sub_vec->sub_nz = 0;
79  sub_vec->values = NULL;
80  sub_vec->values_stride = 0;
81  sub_vec->indices = NULL;
82  sub_vec->indices_stride = 0;
83  sub_vec->local_offset = 0;
84  sub_vec->is_sorted = 0;
85 }
86 
88  const struct RTOp_SubVector *sub_vec
89  ,struct RTOp_SparseSubVector *spc_sub_vec
90  )
91 {
92  spc_sub_vec->global_offset = sub_vec->global_offset;
93  spc_sub_vec->sub_dim = sub_vec->sub_dim;
94  spc_sub_vec->sub_nz = sub_vec->sub_dim;
95  spc_sub_vec->values = sub_vec->values;
96  spc_sub_vec->values_stride = sub_vec->values_stride;
97  spc_sub_vec->indices = NULL;
98  spc_sub_vec->indices_stride = 0;
99  spc_sub_vec->local_offset = 0;
100  spc_sub_vec->is_sorted = 0;
101 }
ptrdiff_t values_stride
Definition: RTOp.h:305
double RTOp_value_type
Definition: RTOp.h:69
void RTOp_sparse_sub_vector(RTOp_index_type global_offset, RTOp_index_type sub_dim, RTOp_index_type sub_nz, const RTOp_value_type values[], ptrdiff_t values_stride, const RTOp_index_type indices[], ptrdiff_t indices_stride, ptrdiff_t local_offset, int is_sorted, struct RTOp_SparseSubVector *sub_vec)
RTOp_index_type global_offset
Definition: RTOp.h:299
const RTOp_index_type * indices
void RTOp_sparse_sub_vector_null(struct RTOp_SparseSubVector *sub_vec)
void RTOp_sparse_sub_vector_from_dense(const struct RTOp_SubVector *sub_vec, struct RTOp_SparseSubVector *spc_sub_vec)
const RTOp_value_type * values
Definition: RTOp.h:303
RTOp_index_type global_offset
const RTOp_value_type * values
RTOp_index_type sub_dim
Definition: RTOp.h:301
Teuchos_Ordinal RTOp_index_type
Definition: RTOp.h:68