/[escript]/trunk/paso/src/SparseMatrix.c
ViewVC logotype

Contents of /trunk/paso/src/SparseMatrix.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1628 - (show annotations)
Fri Jul 11 13:12:46 2008 UTC (11 years, 2 months ago) by phornby
File MIME type: text/plain
File size: 4665 byte(s)

Merge in /branches/windows_from_1456_trunk_1620_merged_in branch.

You will find a preserved pre-merge trunk in tags under tags/trunk_at_1625.
That will be useful for diffing & checking on my stupidity.

Here is a list of the conflicts and their resolution at this
point in time.


=================================================================================
(LLWS == looks like white space).

finley/src/Assemble_addToSystemMatrix.c - resolve to branch - unused var. may be wrong.....
finley/src/CPPAdapter/SystemMatrixAdapter.cpp - resolve to branch - LLWS
finley/src/CPPAdapter/MeshAdapter.cpp - resolve to branch - LLWS
paso/src/PCG.c - resolve to branch - unused var fixes.
paso/src/SolverFCT.c - resolve to branch - LLWS
paso/src/FGMRES.c - resolve to branch - LLWS
paso/src/Common.h - resolve to trunk version. It's omp.h's include... not sure it's needed,
but for the sake of saftey.....
paso/src/Functions.c - resolve to branch version, indentation/tab removal and return error
on bad unimplemented Paso_FunctionCall.
paso/src/SolverFCT_solve.c - resolve to branch version, unused vars
paso/src/SparseMatrix_MatrixVector.c - resolve to branch version, unused vars.
escript/src/Utils.cpp - resloved to branch, needs WinSock2.h
escript/src/DataExpanded.cpp - resolved to branch version - LLWS
escript/src/DataFactory.cpp - resolve to branch version
=================================================================================

This currently passes tests on linux (debian), but is not checked on windows or Altix yet.

This checkin is to make a trunk I can check out for windows to do tests on it.

Known outstanding problem is in the operator=() method of exceptions
causing warning messages on the intel compilers.

May the God of doughnuts have mercy on my soul.


1
2 /* $Id: SparseMatrix.c 1306 2007-09-18 05:51:09Z ksteube $ */
3
4 /*******************************************************
5 *
6 * Copyright 2003-2007 by ACceSS MNRF
7 * Copyright 2007 by University of Queensland
8 *
9 * http://esscc.uq.edu.au
10 * Primary Business: Queensland, Australia
11 * Licensed under the Open Software License version 3.0
12 * http://www.opensource.org/licenses/osl-3.0.php
13 *
14 *******************************************************/
15
16 /**************************************************************/
17
18 /* Paso: SparseMatrix */
19
20 /**************************************************************/
21
22 /* Author: gross@access.edu.au */
23
24 /**************************************************************/
25
26 #include "Paso.h"
27 #include "SparseMatrix.h"
28 #include "TRILINOS.h"
29
30 /**************************************************************/
31
32 /* allocates a SparseMatrix of type type using the given matrix pattern
33 if type is UNKOWN CSR is used.
34 if CSC or CSC_BLK1 is used pattern has to give the CSC pattern.
35 if CSR or CSR_BLK1 is used pattern has to give the CSR pattern.
36 Values are initialized by zero. */
37
38 Paso_SparseMatrix* Paso_SparseMatrix_alloc(Paso_SparseMatrixType type,Paso_Pattern *pattern, int row_block_size, int col_block_size) {
39
40 double time0;
41 Paso_SparseMatrix*out=NULL;
42 Paso_SparseMatrixType pattern_format_out;
43
44 Paso_resetError();
45 time0=Paso_timer();
46 out=MEMALLOC(1,Paso_SparseMatrix);
47 if (! Paso_checkPtr(out)) {
48 out->pattern=NULL;
49 out->val=NULL;
50 out->reference_counter=1;
51 out->type=type;
52
53 pattern_format_out= (type & MATRIX_FORMAT_OFFSET1)? PATTERN_FORMAT_OFFSET1: PATTERN_FORMAT_DEFAULT;
54 /* ====== compressed sparse columns === */
55 if (type & MATRIX_FORMAT_CSC) {
56 if (type & MATRIX_FORMAT_SYM) {
57 Paso_setError(TYPE_ERROR,"Generation of matrix pattern for symmetric CSC is not implemented yet.");
58 return NULL;
59 } else {
60 if ((type & MATRIX_FORMAT_BLK1) || row_block_size!=col_block_size || col_block_size>3) {
61 out->pattern=Paso_Pattern_unrollBlocks(pattern,pattern_format_out,col_block_size,row_block_size);
62 out->row_block_size=1;
63 out->col_block_size=1;
64 } else {
65 out->pattern=Paso_Pattern_unrollBlocks(pattern,pattern_format_out,1,1);
66 out->row_block_size=row_block_size;
67 out->col_block_size=col_block_size;
68 }
69 out->numRows = out->pattern->numInput;
70 out->numCols = out->pattern->numOutput;
71 }
72 } else {
73 /* ====== compressed sparse row === */
74 if (type & MATRIX_FORMAT_SYM) {
75 Paso_setError(TYPE_ERROR,"Generation of matrix pattern for symmetric CSR is not implemented yet.");
76 return NULL;
77 } else {
78 if ((type & MATRIX_FORMAT_BLK1) || row_block_size!=col_block_size || col_block_size>3) {
79 out->pattern=Paso_Pattern_unrollBlocks(pattern,pattern_format_out,row_block_size,col_block_size);
80 out->row_block_size=1;
81 out->col_block_size=1;
82 } else {
83 out->pattern=Paso_Pattern_unrollBlocks(pattern,pattern_format_out,1,1);
84 out->row_block_size=row_block_size;
85 out->col_block_size=col_block_size;
86 }
87 out->numRows = out->pattern->numOutput;
88 out->numCols = out->pattern->numInput;
89 }
90 }
91 out->block_size=out->row_block_size*out->col_block_size;
92 out->len=(size_t)(out->pattern->len)*(size_t)(out->block_size);
93
94 out->val=MEMALLOC(out->len,double);
95 if (! Paso_checkPtr(out->val)) Paso_SparseMatrix_setValues(out,DBLE(0));
96 }
97 /* all done: */
98 if (! Paso_noError()) {
99 Paso_SparseMatrix_free(out);
100 return NULL;
101 } else {
102 #ifdef Paso_TRACE
103 printf("timing: system matrix %.4e sec\n",Paso_timer()-time0);
104 printf("Paso_SparseMatrix_alloc: %ld x %ld system matrix has been allocated.\n",(long)out->numRows,(long)out->numCols);
105 #endif
106 return out;
107 }
108 }
109
110 /* returns a reference to Paso_SparseMatrix in */
111
112 Paso_SparseMatrix* Paso_SparseMatrix_getReference(Paso_SparseMatrix* in) {
113 if (in!=NULL) ++(in->reference_counter);
114 return in;
115 }
116
117 /* deallocates a SparseMatrix: */
118
119 void Paso_SparseMatrix_free(Paso_SparseMatrix* in) {
120 if (in!=NULL) {
121 in->reference_counter--;
122 if (in->reference_counter<=0) {
123 Paso_Pattern_free(in->pattern);
124 MEMFREE(in->val);
125 MEMFREE(in);
126 #ifdef Paso_TRACE
127 printf("Paso_SparseMatrix_free: system matrix as been deallocated.\n");
128 #endif
129 }
130 }
131 }

  ViewVC Help
Powered by ViewVC 1.1.26