473,413 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Array of Array Initialisation

Hi,

I'm writing an FIR filter. The coeffs for low/high/band pass and band
stop (LP,HP,BP,BS) are calculated by matlab and exported as header, e.g.

const int LP_SZ = 33;
const real64_T LP_H[33] = { ... };

const int HP_SZ = 33;
const real64_T HP_H[33] = { ... };

const int BP_SZ = 33;
const real64_T BP_H[33] = { ... };

const int BS_SZ = 33;
const real64_T BS_H[33] = { ... };

Now I want to initialize a new array like:

const real64_T H[4][33] = { LP_H, HP_H, BP_H, BS_H };

which doesn't compile; The error is

fir.h:29: error: initializer element is not constant
fir.h:29: error: (near initialization for `H[0]')

How can I get this to compile, is there a way? Writing

const real64_T H[4][33] = { {...}, {...}, {...}, {...} };

would work, but by change some parameters for FIR filter coeffs I have
to copy & paste it each time again.

The goal ist to use the filter coeffs e.g. in the manner of

int filter_type = 0; // aka LP
filter_fir(H[filter_type], ...);

Thanks
Olaf
Apr 24 '07 #1
2 1817
Olaf P. <is***@inter.netwrote:
const real64_T H[4][33] = { LP_H, HP_H, BP_H, BS_H };
which doesn't compile; The error is
fir.h:29: error: initializer element is not constant
Right; "const" isn't good enough here. Depending on what you need to
do, the following may be what you want:

const real64_T *H[4] = { LP_H, HP_H, BP_H, BS_H };

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
Apr 24 '07 #2
On Tue, 24 Apr 2007 15:06:54 +0200, Olaf P. wrote:
Hi,

I'm writing an FIR filter. The coeffs for low/high/band pass and band
stop (LP,HP,BP,BS) are calculated by matlab and exported as header, e.g.

const int LP_SZ = 33;
const real64_T LP_H[33] = { ... };
Now I want to initialize a new array like:

const real64_T H[4][33] = { LP_H, HP_H, BP_H, BS_H };
How about
const real64_T* H[4] = { LP_H, HP_H, BP_H, BS_H };
(a 4 element array of pointers)

If you had
void filter( const real64_T* coeff, real64_T x);
you could call it like
filter( H[0], x);
Apr 24 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Christopher Jeris | last post by:
I am relatively new to JavaScript, though not to programming, and I'm having trouble finding the idiomatic JS solution to the following problem. I have a table with (say) fields f1, f2, f3. I...
2
by: Remi Bastide | last post by:
Is is possible to initialize a javascript associative array inline, as you would do in PHP, e.g. : <?php $a = array("abc" => "def", "ghi" => "jkl"); ?>
7
by: Michael | last post by:
Hi all, I have got a simple question about the #define command: Can I use it for array initialisation? E.g. #define ARRAYINIT { {0, 1}, {2,3} }
7
by: Frank M. | last post by:
I'm trying to declare an array of pointers to structures so that I can make the last element a NULL pointer. I figure that it would more easily allow my library routines to know when to stop...
18
by: Vasileios Zografos | last post by:
Hello, can anyone please tell me if there is any difference between the two: double Array1; and
3
by: Louis Caron | last post by:
I am facing the following problem: - I have to build a const array containing functions pointers - the indexes for this array are generated automatically by a tool (not my property) How do I...
3
by: mark.bergman | last post by:
Running lint on code initialising a local 2-D array gives a warning. void f(void) { int a = { 0 }; ... lint gives "warning: Partially elided initialisation..." Should this be happening,...
15
by: jamx | last post by:
How can you initialize an array, in the initialization list of a constructor ?? SomeClass { public: SomeClass() : *init here* { } private: int some_array; };
14
by: dan | last post by:
I would like to have the preprocessor automatically generate the number of array elements requested. Each element is zero. The elements get pasted into a larger array. The other elements may be...
31
by: mdh | last post by:
I am still having a problem understanding K&RII on p 112. I have looked at the FAQs --which I am sure answer it in a way that I have missed, so here goes. A 2-dim array, (per K&R) is really a...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.