Clan  0.8.1
vector.c
Go to the documentation of this file.
1 
2  /*+------- <| --------------------------------------------------------**
3  ** A Clan **
4  **--- /.\ -----------------------------------------------------**
5  ** <| [""M# vector.c **
6  **- A | # -----------------------------------------------------**
7  ** /.\ [""M# First version: 01/05/2008 **
8  **- [""M# | # U"U#U -----------------------------------------------**
9  | # | # \ .:/
10  | # | #___| #
11  ****** | "--' .-" ******************************************************
12  * |"-"-"-"-"-#-#-## Clan : the Chunky Loop Analyzer (experimental) *
13  **** | # ## ###### *****************************************************
14  * \ .::::'/ *
15  * \ ::::'/ Copyright (C) 2008 University Paris-Sud 11 *
16  * :8a| # # ## *
17  * ::88a ### This is free software; you can redistribute it *
18  * ::::888a 8a ##::. and/or modify it under the terms of the GNU Lesser *
19  * ::::::::888a88a[]::: General Public License as published by the Free *
20  *::8:::::::::SUNDOGa8a::. Software Foundation, either version 2.1 of the *
21  *::::::::8::::888:Y8888:: License, or (at your option) any later version. *
22  *::::':::88::::888::Y88a::::::::::::... *
23  *::'::.. . ..... .. ... . *
24  * This software is distributed in the hope that it will be useful, but *
25  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
26  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
27  * for more details. *
28  * *
29  * You should have received a copy of the GNU Lesser General Public License *
30  * along with software; if not, write to the Free Software Foundation, Inc., *
31  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
32  * *
33  * Clan, the Chunky Loop Analyzer *
34  * Written by Cedric Bastoul, Cedric.Bastoul@u-psud.fr *
35  * *
36  ******************************************************************************/
37 
38 
39 #include <stdlib.h>
40 #include <stdio.h>
41 #include <ctype.h>
42 
43 #include <osl/int.h>
44 #include <osl/vector.h>
45 #include <clan/macros.h>
46 #include <clan/symbol.h>
47 #include <clan/vector.h>
48 
49 
50 /*+****************************************************************************
51  * Processing functions *
52  ******************************************************************************/
53 
54 
67 osl_vector_p clan_vector_term(clan_symbol_p symbol, int coefficient,
68  char* identifier, int precision) {
69  int rank, size;
70  osl_vector_p vector;
71 
72  size = CLAN_MAX_DEPTH + CLAN_MAX_LOCAL_DIMS + CLAN_MAX_PARAMETERS + 2 ;
73  vector = osl_vector_pmalloc(precision, size);
74 
75  if (identifier == NULL) {
76  // The term is a constant.
77  osl_int_set_si(precision, &vector->v[size - 1], coefficient);
78  } else {
79  // The term is an iterator or a parameter coefficient
80  rank = clan_symbol_get_rank(symbol, identifier);
81 
82  if (clan_symbol_get_type(symbol, identifier) == CLAN_TYPE_ITERATOR)
83  osl_int_set_si(precision, &vector->v[rank], coefficient);
84  else
85  osl_int_set_si(precision,
86  &vector->v[CLAN_MAX_DEPTH + CLAN_MAX_LOCAL_DIMS + rank],
87  coefficient);
88  }
89  return vector;
90 }
osl_vector_p clan_vector_term(clan_symbol_p symbol, int coefficient, char *identifier, int precision)
Definition: vector.c:67
int clan_symbol_get_rank(clan_symbol_p symbol, char *identifier)
Definition: symbol.c:374
int clan_symbol_get_type(clan_symbol_p symbol, char *identifier)
Definition: symbol.c:394