Mercurial > hg > silvet
comparison bqvec/src/Allocators.cpp @ 366:5d0a2ebb4d17
Bring dependent libraries in to repo
author | Chris Cannam |
---|---|
date | Fri, 24 Jun 2016 14:47:45 +0100 |
parents | |
children | af71cbdab621 |
comparison
equal
deleted
inserted
replaced
365:112766f4c34b | 366:5d0a2ebb4d17 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 bqvec | |
5 | |
6 A small library for vector arithmetic and allocation in C++ using | |
7 raw C pointer arrays. | |
8 | |
9 Copyright 2007-2014 Particular Programs Ltd. | |
10 | |
11 Permission is hereby granted, free of charge, to any person | |
12 obtaining a copy of this software and associated documentation | |
13 files (the "Software"), to deal in the Software without | |
14 restriction, including without limitation the rights to use, copy, | |
15 modify, merge, publish, distribute, sublicense, and/or sell copies | |
16 of the Software, and to permit persons to whom the Software is | |
17 furnished to do so, subject to the following conditions: | |
18 | |
19 The above copyright notice and this permission notice shall be | |
20 included in all copies or substantial portions of the Software. | |
21 | |
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR | |
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |
27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
29 | |
30 Except as contained in this notice, the names of Chris Cannam and | |
31 Particular Programs Ltd shall not be used in advertising or | |
32 otherwise to promote the sale, use or other dealings in this | |
33 Software without prior written authorization. | |
34 */ | |
35 | |
36 #include "bqvec/Allocators.h" | |
37 | |
38 #ifdef HAVE_IPP | |
39 #include <ipps.h> | |
40 #endif | |
41 | |
42 #include <iostream> | |
43 using std::cerr; | |
44 using std::endl; | |
45 | |
46 namespace breakfastquay { | |
47 | |
48 #ifdef HAVE_IPP | |
49 | |
50 template <> | |
51 float *allocate(size_t count) | |
52 { | |
53 float *ptr = ippsMalloc_32f(count); | |
54 if (!ptr) throw (std::bad_alloc()); | |
55 return ptr; | |
56 } | |
57 | |
58 template <> | |
59 double *allocate(size_t count) | |
60 { | |
61 double *ptr = ippsMalloc_64f(count); | |
62 if (!ptr) throw (std::bad_alloc()); | |
63 return ptr; | |
64 } | |
65 | |
66 template <> | |
67 void deallocate(float *ptr) | |
68 { | |
69 if (ptr) ippsFree((void *)ptr); | |
70 } | |
71 | |
72 template <> | |
73 void deallocate(double *ptr) | |
74 { | |
75 if (ptr) ippsFree((void *)ptr); | |
76 } | |
77 | |
78 #endif | |
79 | |
80 } | |
81 |