I'm trying to improve my FreeFem++ code by adapting my initial mesh at certain time steps but FreeFem++ comes up with this error message:
Exec error : Try to get unset x,y, ...
after the mesh is indeed adapted. The problems seems to appear when computing the solution in the new mesh, but I haven't had this problem in other cases though. This is how I adapt the mesh in FreeFem++ and update the variables:
Th = adaptmesh(Th,[u1,u2]);
plot(Th);
u1 = u1;
u2 = u2;
p = p;
but now I'm confused on how to proceed after the warning message.
Does anybody know how to solve this? Any piece of advice will be appreciated.
Thanks!
I know this is a very old question, but my following answer is for those who still want to.
I ran into the same error when trying to output (cout) a FE variable uh, it's solved if we try uh[] instead. In this case, it's an array.
Vh uh = x;
cout << uh << endl; // error
cout << uh[] << endl; // good
Hope you can check the same thing for your problem.
Related
I am trying to implement a system so that it retrieves sound and extracts the mfcc of it. I'd like to implement my own mfcc function because librosa library wasn't implemented in C and other implementations of mfcc extractions doesn't yield the same outputs as librosa library does.
So I wrote a code, however, when I would like create hanning window, program doesn't take a step further and always stays the same statement while debugging. The statement is below:
float *mul = malloc(sizeof(float)*fftsize);
The whole code is as follows:
float* hanning(int fftsize){
float *mul = malloc(sizeof(float)*fftsize);
for (int i = 0; i<fftsize; i++){
mul[i] = 0.5 * (1 - cos(2*PI*i/(fftsize-1)));
}
return mul;
}
I put an LCD code to all error handler functions in stm32f7xx_it.c file to determine which fault I'm facing, and I see that it is hard_fault.
So what's the problem? I hope the issue is explained clearly. Due to the privacy, I couldn't put here whole code. Sorry for that. Thx in advance for your response.
Edit: I am chaning malloc to normal array with a variable length array. But still it takes me to HardFault_Handler function. SCB->SHCSR returns sometimes 65535 and sometimes 1.
So technically I have done what the assignment says because this works:
#include <iostream>
using namespace std;
int main()
{
int number = 0;
int sum = 0;
cout << "Please enter an odd positive integer: " << endl;
cout << "This program will end if number is <= 0 or decimal" << endl;
cin >> number;
while (number > 0)
{
if (number % 2 != 0)
sum = sum + number;
else
cout << "That number was even - please enter odd number \n";
cin >> number;
}
cout << "Sum of odd numbers = " << sum << endl;
return 0;
}
However - it dawned on me that the program quits when someone enters a double or enters a character, rather than just warning that this will happen - I would love to write this in. I have tried using else if statements and I am not getting the desired results. I am not asking for someone to solve this for me per se but if I could just get sent in the right direction. We are currently working on while and for loops and increments (which don't seem to apply here at all)
First off, you'd have to change your number variable to a string to take in "anything", deal with garbage input, and finally convert it to an int if it fit your requirements. This usually isn't too hard, but can get tricky at times. Google is usually your friend here. It's bee a while since I did C++, so I'd have to consult it, too, to get things correct.
And when you say "double", is that the number is 2 digits or is too long to be an int? That little bit of ambiguity is throwing me off. If it's just too big a number being an actual double datatype, the string should help with that, as would a problem a 2 digit number.
And for an increment being useful, you could use sum += number;, depending on your version of C++. Older versions don't allow that, but newer versions do. I'd be surprised of a gcc or other compiler wasn't new enough to have it available, at this point.
Side note
Thank you for not being the "typical homework question". It's good that you are just asking for advice, not for someone to write your code for you.
While I've got you, you should think about reading the How To Ask A Question and Tour pages. The Tour gets you another badge, and the other is just good advice to keep people from downvoting or closing your future questions. You already have a good idea on how to ask a homework question, but reading that page is a good idea, too.
But I digress.
Good luck and I hope I put you on the right path.
So I am very confused about the find_conflicts function in CGAL. I thought I knew std::pair, and I thought I knew what was going on in find_conflicts(), but for the life of me, I am not sure how to access the results. I thought that the iterator that is passed to find_conflicts would be enough to then access the values directly. (i.e., I want to get at those facets that I put in the "vector facets,") and it appears as if I'm doing that because I can successfully
typedef std::pair<std::vector<Facet>, std::vector<Cell> > FacetAndCell;
* * *
Cell_handle cell = T.locate(curr_point);
std::vector<Facet> facets;
T.find_conflicts(curr_point, cell, std::back_inserter(facets), CGAL::Emptyset_iterator());
CGAL::First_of_pair_property_map<FacetAndCell> my_p_map();
Delaunay::Finite_facets_iterator ff_iter;
std::vector<Facet>::iterator facet_iter;
// Here, what I'm trying to achieve is figuring out which of the facets
// in conflict are finite. I had wanted to use some kind of test like
// "is_infinite()" on the facet at hand, but this isn't available for
// a facet out of context of the triangulation it's part of.
for(facet_iter = facets.begin(); facet_iter != facets.end(); facet_iter++){
for(ff_iter = T.finite_facets_begin(); ff_iter != T.finite_facets_end(); ff_iter++){
// Since I get an error that facet_iter is actually of type pair, I thought this would work, but it doesn't.
// ERROR!
cout << facet_iter->first << endl;
// This works, which is what led me to believe I was comparing one facet to another facet.
/*
if(*facet_iter == *ff_iter){
cout << "Finite facet!" << endl;
break;
}*/
}
}
In summary:
1) Overall, I want to know which facets from the result of find_conflicts() were finite. If there is an easier way to do this, feel free to let me know.
2) Otherwise, the more specific problem here is that I need to get at that vector of facets that results from find_conflicts() and then get at the vertices of each facet. Am I supposed to be working with the returned "pair" of cells and facets or can I access the vector directly, like I'm trying to do?
Help, please, thanks.
For finiteness testing, use is_infinite(). See http://doc.cgal.org/latest/Triangulation_3/classCGAL_1_1Triangulation__3.html#af024721d3ae4b9327ffe442fb828935c
Otherwise, maybe you are confused because the Facet type is a typedef to a pair (unfortunately).
PS: alternatively, you can use Marc Glisse's suggestion in your other question (using locate(midpoint(p, sphere center))). It might be easier. CGAL Using Locate() to Find Cell on Triangulation Surface
what I need to do is given a edge_iterator and get a halfedge_handle,I checked the cgal document and feel confused
here is my code
for(Edge_iterator ei = mesh.edges_begin();
ei != mesh.edges_end(); ei++){
// get the halfedge handle
}
I know this looks like a silly question, just can't find the answer, thanks
An edge is simply one of the two opposite halfedges.
You can simply write
Halfedge_handle h = ei;
There are next to no noob guides to crypto++ out there. Or none that I've found anyway. What I want to do is decrypt an array of uchars I generate with another AES encrypter. Where would I start? I have the library built and linking grand. Do I need to set anything up or do I just call a function on my array (and if so what function) ?
I'd really appreshiate some help from someone who knows this stuff.
Thanks
I wouldn't say I "know my stuff" too much about this, but here's some test code I put together to encrypt/decrypt strings with AES. Extending this to use some other data shouldn't be too hard.
string output;
CTR_Mode<AES>::Encryption encrypt((const byte*)key,AES::DEFAULT_KEYLENGTH,(const byte*)iv);
StringSource(plaintext, true, new StreamTransformationFilter(encrypt, new StringSink(output)));
cout << "Encrypted: " << output << endl;
string res;
CTR_Mode<AES>::Decryption decrypt((const byte*)key,AES::DEFAULT_KEYLENGTH,(const byte*)iv);
StringSource(output, true, new StreamTransformationFilter(decrypt, new StringSink(res)));
cout << "Decrypted: " << res << endl;
While working on this, I found the source code in the Crypto++ test program (the VisualStudio project called "cryptest") to be a big help. It was a little tough to read at first, but it gets easier as you work with it. I also got a lot of help understanding the available block cipher modes from Wikipedia (http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation).
Here's a couple of resources from a Google search:
http://www.bitvise.com/users-guide.html
http://andreyvit.livejournal.com/37576.html