|
Boost Users : |
From: Fujinobu Takahashi (fjtaka_at_[hidden])
Date: 2005-07-05 09:45:03
Hello Jeremy,
Thank you very much for your very prompt reply for my question.
I tried simple code and works well as follows:
-------------------------------
#include<iostream>
#include<fstream>
#include <boost/dynamic_bitset.hpp>
using namespace std;
using namespace boost;
int main(){
int n=640000; // 80KB = 640kbits data length example
int m=40; // 40(±20)bits shift counters
dynamic_bitset<> bit26(n), bit34(n), bit34m(n);
ifstream fbit26, fbit34;//Two input streams
fbit26.open("26m_80KB.dat", ios::in | ios::binary);
fbit34.open("34m_80KB.dat", ios::in | ios::binary);
fbit26 >> bit26;//copy fbit26 stream dynamic_bitset bit26
fbit34 >> bit34;//copy fbit34 stream dynamic_bitset bit34
bit34m=bit34;
// cout << "bit26 ";
cout << bit26 << endl<<endl;
// cout << "bit34 ";
cout << bit34 << endl<<endl;
long cnt[m];//integration counters for 40 bits
int m2=m/2;
cnt[m2]= (bit26 ^ bit34).count()-n/2;// Counter of shift=20(center)
cout<<"j="<<m2<<" Counts of bit:1= "<<cnt[m2]<<endl;
for (int j=1; j<m2; j++){
cnt[m2-j]= (bit26^(bit34 <<=1)).count()-n/2;//left shift conters
cnt[m2+j]= (bit26^(bit34m >>=1)).count()-n/2;//right shift conters
cout<<"j="<<j<<" Counts of bit:1= "<<cnt[m2-j]<<" "<<cnt[m2+j]<<endl;
}
fbit26.close();
fbit34.close();
return 0;
}
--------------------------------------
Using this code my integration works very well and fast but
cout << bit26 or
cout << bit32
do not work, they are empty!
If possible, would you please show me any concrete hint or a very
introductory sample of the copy of binary file?
Using them I can challenge again to explore a mystery of dynamic bitset.
Very thanks,
Fuji
On Thu, 30 Jun 2005 13:46:00 -0500
Jeremy Siek <jsiek_at_[hidden]> wrote:
> Hi Fuji,
>
> The dynamic_bitset construtor that takes a input iterator over blocks
> was meant
> for this kind of construction. It would be up to you to obtain/create
> the iterator.
>
> template <typename BlockInputIterator>
> explicit
> dynamic_bitset(BlockInputIterator first, BlockInputIterator last,
> const Allocator& alloc = Allocator());
> Effects: Constructs a bitset based on a range of blocks. Let *first be
> block number 0, *++first block number 1, etc. Block number b is used to
> initialize the bits of the dynamic_bitset in the position range
> [b*bits_per_block, (b+1)*bits_per_block). For each block number b with
> value bval, the bit (bval >> i) & 1 corresponds to the bit at position
> (b * bits_per_block + i) in the bitset (where i goes through the range
> [0, bits_per_block)).
> Requires: The type BlockInputIterator must be a model of Input Iterator
> and its value_type must be the same type as Block.
> Throws: An allocation error if memory is exhausted (std::bad_alloc if
> Allocator=std::allocator).
>
>
>
> On Jun 30, 2005, at 10:16 AM, Fujinobu Takahashi wrote:
>
> > Hello,
> >
> > I would like to try one-bit correlation between two one-bit sampling
> > VLBI data files using powerful dynamic bitset library.
> > (VLBI:Very Long Baseline Interferometer)
> >
> > A binary file japan.dat includes one-bit sampling data of a quasar
> > received at a Japanese antenna and another binary file usa.dat
> > includes one-bit sampling data of a same quasar received
> > simultaneously at a US antenna. The bitset block size should be more
> > than 10Mbits
> >
> > What kind of constructor codes should I write to copy the
> > bit-pattern of each data file to each very long dynamic bitset? I
> > am sorry but I could not find any good answer from Google search.
> >
> > I am looking forward to helpful answer in this mail-list.
> >
> > Very Thanks
> >
> > fuji
> >
> >
> > _______________________________________________
> > Boost-users mailing list
> > Boost-users_at_[hidden]
> > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> >
> _______________________________________________
> Jeremy Siek <jsiek_at_[hidden]>
> http://www.osl.iu.edu/~jsiek
> Ph.D. Student, Indiana University Bloomington
> C++ Booster (http://www.boost.org)
> _______________________________________________
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net