|
And what exactly is wrong with using a loop for this purpose? I'm not exactly sure what you want to OR, but if you want to perform bitwise operations on the two numeric arrays, looping and storing the data in another array is a perfectly fine way of doing so.
|
|
|
|
|
Being arrays hugh loop takes 4-5 seconds.
so i want to reduce this time to 2-3 seconds.
|
|
|
|
|
Well, what I don't understand is... looping is a concept, so it's not inherently slow unless your algorithm is crappy. If you have 100 pieces of data, and you want to process them all, you have to create a loop that goes through everyone of them. An array (to my inexperienced self), is quite a simple data structure, basically, an initial value and offsets of size sizeof(type), all contiguous in memory, which should be very fast to access. You only have to loop through all of this data once. You do not have to revisit them. Just something like:
int array_A[100];
int array_B[100];
int array_C[100];
for (int i = 0; i < 100; i++)
{
array_C[i] = array_A[i] | array_B[i];
}
I don't know if it gets any simpler than that...correct me if I'm wrong.
|
|
|
|
|
I dont know whether i am looking for is possible or not?
what i want e.g if i have to assign 10000 elelemts in loop will take siginifancatly more time than a memcpy or memmove call. similarly something like memcpy or memmove is there anything that can speed up this or operation.
|
|
|
|
|
How huge of a loop takes 4-5 seconds???
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Borrowing from Cyrilix's code, here's code ORing two 50MB arrays of integers (200MB total bytes
each).
It takes much less than a second on my machine
int *array_A = new int[52428800];
int *array_B = new int[52428800];
int *array_C = new int[52428800];
for (int i = 0; i < 52428800; i++)
{
array_C[i] = array_A[i] | array_B[i];
}
delete[] array_A;
delete[] array_B;
delete[] array_C;
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Can anyone help me to get answers to my these two questions :
1. How can I copy a file bit -by- bit? And also store that bit temporarily in any variable.
2. How to write a single bit in file? Is this method write.
fstream dfile;
char bit = '1';
dfile<<bit-48;
what does="" the="" above="" code="" writes="" to="" dfile="" a="" byte="" or="" bit.???
codes="" compiled="" in="" borland="" c++="" 3.0="" will="" be="" nice="" for="" me="" cos="" i'm="" using="" that="" as="" my="" compiler
--="" modified="" at="" 12:24="" thursday="" 21st="" june,="" 2007
manmohan="" bishnoi=""
<div="" class="ForumSig">Manmohan Bishnoi
|
|
|
|
|
The smallest I/O resolution you have is one byte so you'll have to work with 8 bits at a time.
You can use bitwise and shift operators to manipulate bits in a byte.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Recently I begin to program with GDI+,and I want to contruct a Bitmap object with the function Bitmap( Class type, String resource ),because my bitmap is in resource(is it right to use the function?).But I don't know how to set the parameters "type" and "resource"~ Help~
|
|
|
|
|
Construct CBitmap object to first load the bitmap from resource.
Then use that object to get the handle of bitmap.
Finally ,from that handle you can construct a GDI+ Bitmap object by using
Bitmap::FromHandle() function.
|
|
|
|
|
Or you can use this constructor:
Bitmap(HINSTANCE, const WCHAR *)
e.g.
Gdiplus::Bitmap bitmap(hInst, MAKEINTRESOURCEW(IDB_BITMAP));
Mark
-- modified at 0:02 Friday 22nd June, 2007
Fixed Typo
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hello,
I want to display tooltips in Wnd when the mouse is in some rect. So i use ON_NOTIFY(TTN_NEEDTEXTW, 0, OnToolTipNotify) and ON_NOTIFY(TTN_NEEDTEXTA, 0, OnToolTipNotify) Like,
void CLadderWnd::OnToolTipNotify(NMHDR *pNMHDR, LRESULT *pResult)<br />
{<br />
TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;<br />
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;<br />
...<br />
CString str = "abcd\n1234";<br />
pTTTA->lpszText = (LPSTR)(LPCTSTR)str;<br />
}
I hope display text with multiline, but it will output just one line and display "abcd1234". I have tried "\r\n" or "\r" and they are the same.
How can I do it!
Thanks!
|
|
|
|
|
|
How can i modify BIOS-CMOS password ?
How can i change boot order embedded in BIOS ?
Thank you very much
|
|
|
|
|
Sorry for my poor English .
Press del key after the check of hardware , and then you would come into BIOS setup interface .
|
|
|
|
|
I think he want to do with c++.;)
|
|
|
|
|
I am asking how to program it from Windows user or kernel mode...
|
|
|
|
|
|
Your answer is good but it has a problem we are on the c++ forum but your link is on the C# (WMIQuery).
|
|
|
|
|
|
Wow Mr/Mis zhang we have a new problem now I think some people cant see your link its china and also previous link was china,do you have any idea about new problem.
|
|
|
|
|
I would like to check for the existance of a file before I create it, since I dont want to recreate the file if it exists. The help in visual studio 2005 mentions EXIST operator but does not give a clue as to the syntax for using it. Can someone please enlighten me with the code to make this work?
Thanks alot,
Terry
|
|
|
|
|
SimplCodr wrote: I would like to check for the existance of a file...
Can you use _access() ?
SimplCodr wrote: ...since I dont want to recreate the file if it exists.
Do you just want to append to it?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
That worked perfectly, thank you very much.
Terry
|
|
|
|
|
Or you can use of FindFirstFile and check return value of this function.
|
|
|
|