« first day (61 days earlier)      last day (2798 days later) » 
05:00 - 16:0016:00 - 18:00

5:15 AM
Hi everyone
I'm using CVM Class Library, but the set function of the basic_schmatrix class is throwing a cvmexception
Would you please give me a help?
more information is here in the following question
0
Q: set member function of the schmatrix class in cvm library is throwing an exception but why?

sepidehI've created a mex function through adding the following code in mx_minimum_power.cpp #include <math.h> #include <complex> #include "mex.h" #include "matrix.h" #include "cvm.h" #include "blas.h" #include "cfun.h" using std::complex; using namespace cvm; /* The gateway function */ void mexFunct...

 
 
3 hours later…
nwp
8:48 AM
@sepideh the reason is most likely that you use casts and break the type system
float *inMatrixA11 = (float *)mxGetPr(prhs[0]); and complex<float> *inMatrixA12 = (complex<float> *)mxGetPr(prhs[1]); are most likely wrong
 
9:47 AM
@nwp Have you seen the this photo
it shows that those lines are not wrong
 
nwp
@sepideh does it? looks like garbage values to me
 
10:00 AM
it shows that
inMatrixA11[0]= 0.152335599
inMatrixA12[0]= -0.0366497301-0.0366757624 i
inMatrixA13[0]= 0.0309482180+0.0305216759 i
inMatrixA22[0]= 0.107748874
inMatrixA23[0]=-0.015332432-0.0353592485 i
inMatrixA33[0]=-1.29370940
just before executing the line:

A.set(1, 1, inMatrixA11[i]);
that is just as my expectations. because I'm passing [these matrices](http://i.stack.imgur.com/LUUwz.jpg) to the mex function
 
10:49 AM
ideone.com/ihoTJ0 @milleniumbug its done thanks
 
 
2 hours later…
12:52 PM
there's no difference (context)
you could as well write callback = (******************char_print);
 
user4710450
Hi all
 
user4710450
#include <stdio.h>
#include <pthread.h>

struct char_print_params {
    char character;
    int count;
};

void* char_print(void* parameters) {
    struct char_print_params* p = (struct char_print_params*) parameters;
    for (int i = 0; i < p->count; ++i)
        fputc(p->character,stderr);
    return NULL;
}

int main() {
    pthread_t thread1_id;
    pthread_t thread2_id;

    void* (*callback)(void*);
    callback = &char_print;

    struct char_print_params thread1_args;
    struct char_print_params thread2_args;
 
user4710450
In code above :
 
user4710450
callback = &char_print;

&

callback = char_print;
 
there is no difference
 
user4710450
1:04 PM
What is the difference between these 2?
 
user4710450
Why?
 
user4710450
&char_print
 
user4710450
is a pointer
 
function type gets decayed at assignment
function pointers are special beasts
different from your regular data pointers
pretty much any operation on a function (except calling it) will decay it to function pointer
 
user4710450
Thanks for your help!
 
1:05 PM
so you can do (************char_print)
 
user4710450
Wow! Thats awesome!
 
and the function will be decayed to a function pointer, dereferenced, and decayed again because operator* doesn't apply to function types
several times
 
1:31 PM
ok so im back
if anyone wants to help with my project a little
made quite a bit of progress
 
user4710450
1:50 PM
Hi
 
Hi
 
user4710450
Could you please take a look at this :
http://pastebin.com/zi1dmMRd
 
Oh I wouldn't ask me
I'm learning
I'll look anyway though
 
user4710450
@exitc0de Thanks :P
 
Yep you know more than me, I can't really help @Ehsan
 
user4710450
1:52 PM
And please put a URL to your project
 
user4710450
I will have your back :D
 
user4710450
@exitc0de Thats OK.
 
sec
 
user4710450
Is it on github?
 
sorry was just updating the repo
 
user4710450
1:57 PM
@exitc0de Your welcome!
 
user4710450
I was also having a nice chat with friends in :
http://chat.stackoverflow.com/rooms/44914/ruby-sometimes-on-rails
 
user4710450
@exitc0de So what happened to your tiny project?
 
Oh its a big project
I just haven't done anything
and its super basic
I'm making a nuclear war game effectively
where you play a continent
and you have to survive
 
user4710450
@exitc0de Happy to hear that :)
 
its text based
so eventually the way it will work is there are a load of random events that can happen
 
user4710450
2:01 PM
@exitc0de Sounds interesting :P
 
so Japan might nuke China
 
user4710450
@exitc0de lol
 
and it will ask you if you want to help Japan or China
And if you help one
 
@Ehsan You really should be using C++11 <thread> instead
 
they might help you
and the other might retaliate
 
user4710450
2:02 PM
@milleniumbug I am learning POSIX API
 
@milleniumbug @Ehsan github.com/exitc0d3/Contingency-Project/blob/master/main.cpp what I have so far <-
I don't know very much so its pretty difficult at the moment
 
user4710450
Nice also try to document it more so I know what you are doing at all :|
 
will do
 
user4710450
Fuck it >:-(
 
user4710450
I don't know why the hell the paste bin doesn't work :(
 
2:05 PM
use gists
 
use ideone or coliru
 
user4710450
I'm feeling sick of C : NO exception , no clue what's going on
 
user4710450
@milleniumbug I am using CLion currently
 
I mean for posting code online
 
user4710450
The thread is created because pthread_create returns 0
 
user4710450
2:06 PM
@milleniumbug Sorry ide-one ( the ide part ) was a bit misleading :)
 
user4710450
@milleniumbug Thanks
 
user4710450
 
user4710450
Here it is
 
user4710450
plz take a look at it I don't know why the fucking its not printing anything :(
 
user4710450
2:10 PM
This is the reason C is falling :
 
user4710450
No exception handling
 
user4710450
Yet I have to deal with it as University makes us!
 
nwp
@Ehsan your program exits before the threads have a chance to do anything
 
yep indeed
 
user4710450
Why? Whats the problem?
 
nwp
2:17 PM
compare with this
 
user4710450
Hmm.. Sorry
 
nwp
pthread_join makes the main thread wait until the threads are done
 
user4710450
The book has written this after the code snippet
 
Ok @milleniumbug I've added some documentation and the way I've done it is having a different object for each region which has its own values for the weapons
 
user4710450
lol. How stupid I was!
 
2:18 PM
so that the weapon values can change individually
 
user4710450
Guys, sorry for wasting your time :(
 
Hello everyone, glad i got this feature unlocked. its my first chat here. will try to help here as well :)
 
user4710450
Hi @MukulChauhan!
 
user4710450
@MukulChauhan You could ask the moderator also
 
nwp
@Ehsan your program should also work correctly if the code inside assert doesn't run, which it currently doesn't
 
2:20 PM
right I finally setup my git repo properly, everything is here: github.com/exitc0d3/Contingency-Project/blob/master/main.cpp
Feel free to tell me whether I've screwed everything up again @milleniumbug
Its still messy
 
user4710450
btw, delete .vscode directory
 
nwp
@exitc0de why the getters and setters?
 
@nwp I wanted the weapon variables to be private
 
hi :) Question, --> if in c++ is a loop or statement ?
 
so I didn't mess it up
 
user4710450
2:21 PM
What should this happen to be exactly?
 
user4710450
Weapon icbm;
 
inter continental ballistic missile
its a type of weapon
 
user4710450
@MukulChauhan statement
 
so Weapon is a custom data type
 
user4710450
@exitc0de Also avoid abbreviations as possible and use comprehensive names for variables :)
 
2:22 PM
@Ehsan surely it's meaningful in context
@MukulChauhan yes
 
user4710450
And also put Isreal on the countries list xD
 
I think in this case I'm happy for them to be abbreviations because in the game they will be called by their abbreviations @Ehsan
 
nwp
@exitc0de you should consider adding a file .gitignore to your project to make git ignore project files
 
I did but I dont think it worked @nwp
 
nwp
ah, it only ignores future files, not files that were already added
 
2:24 PM
agh any way to get round that?
 
nwp
1648
Q: Ignore files that have already been committed to a Git repository

trobrockI have an already initialized Git repository that I added a .gitignore file to. How can I refresh the file index so the files I want ignored get ignored?

 
user4710450
Could you please accept my pull requests?
 
Done
 
user4710450
Good project yet :)
 
user4710450
I really recommend you use CLion
 
user4710450
2:31 PM
It makes life much easier
 
user4710450
Don't worry about the license
 
user4710450
I will give one to you :D
 
if you're a student you can get a student's license from JetBrains for any of their products
 
user4710450
@milleniumbug Yup but I am using some other thing
 
user4710450
Called patch.jar
 
user4710450
2:33 PM
It's a nasty crack xD
 
user4710450
I have my subscription until 2099
 
user4710450
If I live that long!
 
Visual studio code is fine once you get everything setup
Its just a bit annoying sometimes
but I like the plugins and color themes
and the fact I can get it on anything
 
user4710450
I know this violates CopyRight and more importantly humanity but I need that money :|
 
user4710450
2:35 PM
@exitc0de It has nothing compared to CLion. Give it a try
 
user4710450
And you will abandon VS Code!
 
not sure about that
I think I tried the trial once
I can't use cmake either
 
user4710450
@exitc0de Um, OK.
 
I'll give it a go sometmes
*sometime
 
user4710450
You know I'm historically in love with JetBrains products
 
user4710450
2:37 PM
I don't forget the day I get relieved of Eclipse Intellij saved me :)
 
hehe, Eclipse
 
eclipse is horrific
I know that much
 
or, as I like to call it, "basic features randomly breaking"
 
user4710450
Does anyone on the earth like Eclipse?
 
when it works it's tolerable
but it rarely does
 
2:39 PM
@milleniumbug is the way I have everything setup better now
 
user4710450
It's rubbish
 
still a bit repetitive
 
user4710450
because you have to configure every single thing you want to use
 
I installed it once on linux and cursor wasn't shown
 
haha
 
2:39 PM
try editing text with no cursor :D
 
user4710450
@milleniumbug OMG
 
so you could type stuff, but you didn't know where the text will appear
 
@milleniumbug I'm worried I've made the wrong things private and public
 
user4710450
What do you want to exactly make private?
 
user4710450
Nothing in a C++ project needs to be private!
 
2:40 PM
good practice and all that
I have absolutely no idea how I'm gonna manage events
 
user4710450
Come on! What kind of security thing do u have in ur project?
 
Oh
and if each region
has allies and enemies
which are the other region classes
I don't know I'm going to deal with that
 
user4710450
.gitignore is a must-do for a Rails project because if ppl see somethings ur website will be hacked easily but in C++ project I thing there is nothing like that :P
 
user4710450
@exitc0de, have you written a plan for your game at all!?
 
know how everything will play out
 
user4710450
2:43 PM
It seems you are just adding features!
 
but no idea how to implement anything
 
user4710450
@exitc0de Shouldn't a developer know about it so they can modify your game?
 
user4710450
First of all make a written plan of your game preferably
 
user4710450
Take a look here :
https://opensource.org/
 
@Ehsan what do you mean
I need a plan
yes
I'll work on one
and then i'll write a file about features
 
user4710450
2:45 PM
Take a look at the definition of open source softwares
 
I know what open source software is
 
user4710450
In your project nothing needs to be hidden
 
Oh I mean the class variables
whether they should be private or public
 
user4710450
Um, sorry
 
nw!
I know nothing about making collaborative stuff anyway
 
user4710450
2:47 PM
@exitc0de Me too!
 
Ok I'll work on a timescale
so each second has a chance of calling a random event
and only one event can be handled at a time
so one will only be called if one is not already in progress
 
user4710450
 
user4710450
Thats the way git works! lol
 
user4710450
I have really experienced that :|
 
user4710450
If something went wrong I just deleted the project and pushed it again and worked on it
 
2:51 PM
How should I setup a time system
So in the game
I'm gonna have to have multiple threads
or something
 
no, not really
 
but if I just have a while loop where time increases every new running of the loop
it wont be increased once per second
I will have just the standard game loop
 
user4710450
why not use sleep?
 
"I guess I'll just use threads. I Now two problems have"
 
user4710450
Not sure its available in Windows, though.
 
2:53 PM
yes but the problem is I can't have two loops running at the same time
so I might have
while (!quit) { sleep(1); time++; }
and also the game loop
 
tbh your project may be a little too big for you now
 
Good way of learning tho
as I get to each new problem
I learn the relevant stuff
 
user4710450
@milleniumbug Yeah, try something easier now
 
I just need a few pointers
There isn't really much else I want to do
 
user4710450
@exitc0de for what!?
 
2:55 PM
No as in a few suggestions as to how I might do things
So that I can then learn how to do those things
 
heheheheheh that language confusion
 
Im going to have to use threads though right @milleniumbug
 
user4710450
lol
 
this is a game after all
 
why no
 
2:56 PM
and I can't increment time every second but also have my game loop running?
 
user4710450
Do you know threads or you are going to learn?
 
I wrote a multiplayer bomberman style game server for 4 players without using threads
 
I'm wandering whether I need them
So that I can then learn them
how else without threads am I going to have two loops running at the same time
 
you don't need two loops running at the same time, duh
 
user4710450
@exitc0de Come on! Read a book or take a course then write your own game :)
 
2:58 PM
I've read books
How do I ensure that each update of the loop happens every second
or every 1/60th of a second
like a FixedUpdate() {} function in a game engine
Do I make an update function and then call that in main every 1/60th of a second
That'll work right @milleniumbug
 
user4710450
By the way
 
if I actually get all this ground work done
It wont be so hard
 
user4710450
Take a look at this :
 
user4710450
It may be a good inspiration
 
3:02 PM
thanks
will take a look
I just need to look at the source of a few simple games
that aren't too simple
wtf
 
user4710450
Yup, you should it really gives you the idea :P
 
who separates the return value of a function onto a different line
to the actual declaration?
 
user4710450
Everyone has their coding style
 
fair enough
never seen that one before
the problem for me is getting my head around the classes and stuff
and all the different functions
I'll figure it out though
 
user4710450
Yup C programs are like spaghetti
 
3:05 PM
still not sure how to setup a timer though
 
user4710450
300 lines of code
 
user4710450
 
user4710450
lol
 
I'll just set it up so that the Update function is a while loop
that updates every second
because its text based
so 1fps
:)
how do I pause time in a c++ program
so equivalent to time.sleep(1) in python
 
how many seconds does this sleep
 
3:15 PM
got a function
void sleep(unsigned int mseconds)
{
clock_t goal = mseconds + clock();
while (goal > clock());
}
there we go
I'll use that
I know ctime uses CPU cycles
 
std::this_thread::sleep_for(std::chrono::milliseconds(1));
 
so no idea how well this whole thing will work
eh
which way is better @milleniumbug
 
your way busy loops
 
Im having to measure elapsed time at end of update loop and if it is under 1 second wait for remainding time
 
user4710450
Guys, good night :)
@exitc0de, Hope you do well in your project!
 
3:27 PM
void Update() {
bool run = true;

while(run) {
clock_t begin = clock();

cout << "second has passed";

clock_t end = clock();
double elapsed_secs = double(end - begin);
double remainding_secs = 1-elapsed_secs;

if (elapsed_secs < 1)
{
sleep(remainding_secs);
}

}
}
this doesn't seem to be working:
it doesn't print second has passed every second
 
clock() has 1 second precision (laffo)
use <chrono> instead
 
ah
 
auto begin = std::chrono::high_resolution_clock::now(); // AFAIR that's how it goes
 
because it now prints that elapsed_secs is 0
and then I can just do the same but equal to auto end when I'm done?
error begin does not name a type @milleniumbug
does that mean I'm using C++ 03 and not 11
 
maybe
 
3:33 PM
is the g++ compiler flag for C++ 14 just -14
or -cpp14
I'll google it dw
 
-std=c++14
 
ah thanks
 
auto end yeah, the same
now converting it to a printable format is always fun
 
ah
 
can never remember how it's done
 
3:35 PM
g++: error: unrecognized command line option ‘-std=c++14’
aghhhghhgh
 
too old
upgrade
g++ --version tells you version you use
 
AHAHGHA
Ubuntu on windows
wont let
me use the latest version of G++
whyyyy
std::chrono has not been declared should I include something @milleniumbug
 
7 mins ago, by milleniumbug
use <chrono> instead
 
ah yes
main.cpp:210:49: error: invalid cast from type ‘std::__success_type<std::chrono::duration<long int, std::ratio<1l, 1000000000l> > >::type {aka std::chrono::duration<long int, std::ratio<1l, 1000000000l> >}’ to type ‘double’
double elapsed_secs = double(end - begin);
ouch
GOT IT
    std::chrono::duration<double> diff = end-start;
Its not liking this: @milleniumbug
while(run) {

auto begin = std::chrono::high_resolution_clock::now(); // AFAIR that's how it goes

cout << "second has passed\n";

auto end = std::chrono::high_resolution_clock::now();

std::chrono::duration<double> elapsed_secs = double(end - begin);

cout << elapsed_secs << endl;

double remainding_secs = 1-elapsed_secs;

if (elapsed_secs < 1.0)
{
cout << remainding_secs << endl;
sleep(remainding_secs);
}

}
 
"Its not liking this" is not a problem statement
 
3:43 PM
trust me you dont want the error log
 
find the first error and point which line it points to
don't look at the errors, look at the lines
 
main.cpp: In function ‘void Update()’:
main.cpp:210:72: error: invalid cast from type ‘std::__success_type<std::chrono::duration<long int, std::ratio<1l, 1000000000l> > >::type {aka std::chrono::duration<long int, std::ratio<1l, 1000000000l> >}’ to type ‘double’
std::chrono::duration<double> elapsed_secs = double(end - begin);
main.cpp:212:17: error: cannot bind ‘std::ostream {aka std::basic_ostream<char>}’ lvalue to ‘std::basic_ostream<char>&&’
cout << elapsed_secs << endl;
main.cpp:214:35: error: no match for ‘operator-’ (operand types are ‘int’ and ‘std::chrono::duration<double>’)
double remainding_secs = 1-elapsed_secs;
 
okay so this line is erroring out and you get a cascade of errors
std::chrono::duration<double> elapsed_secs = double(end - begin);
 
im just converting it wrong
 
(end - begin).count() will give you the count in "ticks"
 
3:48 PM
auto nanos = duration_cast<nanoseconds>(now.time_since_epoch()).count();
apparently that might work
I'll give it a go
thank god for so
 
...except it's (end - begin) instead of (now.time_since_epoch())
 
do you think if I replace now with begin
it will tell me the time since begin?
I assume time_since_epoch gives that
 
no
2 mins ago, by milleniumbug
...except it's (end - begin) instead of (now.time_since_epoch())
 
I dont really want to work with nano seconds
a nano second is a billionth of a second
thats gonna be a tricky one
this should work right: auto nanos_duration = duration_cast<std::chrono::milliseconds>(end - begin); @milleniumbug
 
sure this will lose precision but vOv
also the name of the variable is now misleading
 
3:57 PM
yeah I changed that
still get a tonnnnnne of errors
main.cpp: In function ‘void Update()’:
main.cpp:212:17: error: cannot bind ‘std::ostream {aka std::basic_ostream<char>}’ lvalue to ‘std::basic_ostream<char>&&’
cout << duration << endl;
^
In file included from /usr/include/c++/4.8/iostream:39:0,
from main.cpp:6:
/usr/include/c++/4.8/ostream:602:5: error: initializing argument 1 of ‘std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = std::chrono::duration<long int, std::ratio<1l, 1000l> >]’
 
05:00 - 16:0016:00 - 18:00

« first day (61 days earlier)      last day (2798 days later) »