784 questions
5
votes
0
answers
265
views
Am I over-encouraging people to use shared_ptr's? [closed]
In this earlier SO question:
What is a smart pointer and when should I use one?
Ten years ago, I gave a relative simple answer and got a bunch of upvotes. One paragraph in my answer reads:
Use std::...
1
vote
1
answer
133
views
Triangular mesh decimation that preserves watertightness in python
The title pretty much says it all. So far I've tried Fast-Quadratic-Mesh-Simplification, but as the documentation on the original c implementation says, it only preserves watertightness if there are ...
1
vote
1
answer
100
views
Making solveset solutions rational in sympy
I'm trying to solve a cubic with a parameter r, for x. The cubic is the awful expression
poly = b*(-(10 + x)*b - 10*b) - ((8/3) + x)*((10+x)*(1+x) - 10)
where
b = sp.sqrt((8/3)*(1 - a))
which ...
0
votes
2
answers
139
views
How to get original indicies of a polygon after applying shapely.simplify?
This Python script:
from shapely import simplify, points, contains, Point
circle = Point(0, 0).buffer(1.0, quad_segs=8).exterior
simple = simplify(circle, 0.1)
simplifies polygon circle (red) and ...
0
votes
2
answers
105
views
sympy simplify expression with power-reduction formula
I have the following sympy expression
>>> a
⎛2⋅π⋅(x - y)⎞
2 - 2⋅cos ───────────
⎝ P ⎠
which I would like to simplify to
2 ⎛π⋅(x - y)⎞
4⋅sin ─────────
...
2
votes
3
answers
664
views
Simplify Polygon shapefile to reduce file size in python
I have a polygon shapefile which was vectorized from a raster layer (second image). This shapefile contains thousands of features with just one column which represent polygon level (ranging 1-5). The ...
1
vote
3
answers
131
views
How to simplify the following regular expression? [closed]
I need to match 20 numbers in a string as follows,and then do a text replacement:
0.61 -0.60 0.06 0.46 1.07 0. 0.47 0.07 0.61 -176.
1.53 1.15 -176 176 ...
0
votes
0
answers
72
views
Is sympy's simplify to be used on unknown functions?
The following code unexpectedly simplifies f(1)=xf(0) to f(1)=0. Is it because undefined functions are not to be used without further assumptions?
Running this should not change the expression, but it ...
0
votes
2
answers
69
views
Is there an easy way to separate out model coefficient values into different variables?
I am looking to simplify the following:
> model$coefficients
(Intercept) x1 x2 c
-1.51730659 0.28487690 0.10034603 0.08629699
b0_i = model$coefficients[1]
...
0
votes
0
answers
97
views
Improve/shorten R code for processing spatial objects
I am self-taught in R and would like to improve my coding skills. My codes often contain repetitive commands and produce many individual results. I also often find it difficult to combine them into a ...
-6
votes
5
answers
732
views
function to simplify adding custom property to powershell select
Powershell can add custom properties with somewhat messy syntax, as described in the about_Calculated_Properties help topic; e.g.:
Get-Date | Select-Object Year, @{name='foo'; expression={123}}
Year ...
1
vote
0
answers
59
views
Combining derivatives when taken with respect to the same variable
Is there a way to collect derivatives w.r.t. the same symbol in a sum?
There are several questions that go around this point, but I haven't found an answer for the simple situation:
from sympy import *...
0
votes
1
answer
53
views
Simplifying Eliminating Duplicate Columns SQL
I have the following code:
update tble
set
offer_id_02 = offer_id_03,
offer_id_03 = offer_id_04,
offer_id_04 = offer_id_05,
offer_id_05 = offer_id_06,
offer_id_06 = offer_id_07,
offer_id_07 = ...
0
votes
2
answers
340
views
How is this (xy)' + (yz) simplified into this (x’+y’)+z in boolean algebra? [closed]
I not understand how the first Boolean expression on the question can be simplified into the last. Please help me.
My attempt:
1. (xy)' + (yz)
2. (x' + y') + (yz) # Using de Morgan's law.
3. x' + (y' +...
0
votes
1
answer
43
views
Maple simplify - expression of vars through other vars
I have a string
W := lx1sx1ph11alpha1ph12beta2-lx1sx1ph12alpha2ph11beta1+lx2sx2ph11alpha1ph12beta2-lx2sx2ph12alpha2ph11beta1
I want use the simlify with the condition to remove sx1 and sx2:
Right := ...
0
votes
2
answers
63
views
Why won't my shortened JavaScript code for changing my HTML work?
I have working code that changes my HTML and arranges classes and data from highest to lowest, but it is very lengthy. I would like to make it shorter. I recently learned JavaScript this week, so it ...
0
votes
1
answer
100
views
Unyt module for python - how to use correctly .simplify()?
I am using Unyt module for python and found unexpected, resp. "unintuitive" results.
In simple code I tried to brake down problem.
What I am trying to achieve:
a = 23\*kN/m
b = N/m
c = a/b ...
0
votes
1
answer
92
views
How to turn several rows of values into one row in R [duplicate]
I am simplifying and summarizing my data so that I can run an ANOVA on it so I want to compress the rows in one column into less rows. I feel like it only makes sense looking at the data so,
this is a ...
2
votes
1
answer
54
views
How to simplify my double loops by matlab vectorization?
My code is :
N = 500; %
D_1=ones(N,N);%
D_2=ones(N,N);% For simplicity.
B=zeros(N,N);
for i = 1:N
for j = i+1:N
basis_vector = zeros(N, 1);
basis_vector(i) = 1;
...
-1
votes
1
answer
106
views
How to simply this nested code the best ? Note: need to call two different default cases here
if( auto id:{k_b0,k_b1}){
auto baseIndex = 0;
auto count = false;
if(!rmt){
switch(src){
case a: {if(slow) {count = Getconfig(); baseindex =0;}
else {count = GetslowConfig(); baseindex =4;}}...
2
votes
1
answer
146
views
Simplest way to use `CGAL::simplify` on a 2D Arrangement?
I have a CGAL 2D Arrangement, and I would like to simplify each sequence of egdes separated by degree-2 vertices using CGAL::simplify. Is there a simple way to do that, or do I have to do something ...
0
votes
0
answers
44
views
Simplifying equations created from a matrix
Good day! I'm trying to write a python script that can model the temperature of a space.
I've chosen an 11x11 matrix to represent this space, the edges are 20 degrees, and the centre is 3000 degrees.
...
-2
votes
1
answer
223
views
Simplification of a logical expression for logic (laws of logic algebra)
I am currently trying to learn how to simplify logical expressions. But I'm stuck on this problem where I have to simplify this expression using the laws of logic (Boolean algebra).I would like some ...
0
votes
1
answer
82
views
Is there a way to simplify this code creating css variables with javascript for specific breakpoints on my webpage?
I am using this bit of javascript code to create a string with css variables in it.
It helps me to specifically set a size for each breakpoint on a webpage.
This is my code:
const sizes = {
xs: 0.9,
...
-1
votes
1
answer
44
views
Move logic into map in return part [closed]
So I want to simplify this Code by moving it
for (let i = 0; i <= 15; i++) {
const generationId: number = shuffeledIdArray[i];
cards.push({
element: (
<Card
...
0
votes
0
answers
73
views
How to simplify the use of too many IF statements when finding specific cases
I have code which a user will select different perameters from 5 dropdown menus, these can be: "None", 'Name', 'Manager', 'AccessLevel', 'Inhabitant' and 'Location' these will be matched ...
0
votes
0
answers
38
views
Maintain Useful commented codes in separate class in C#
I have a useful commented codes in every classes as below which are used for future references .Is there is any alternative way to effectively maintain commented codes in difference class and can be ...
0
votes
1
answer
88
views
How do I use SymPy to simplify by substitution a number of equations to get to a single simplified equation?
My question is exactly like the title of my post. Attached is an image with an example of what I would like to achieve.
Description of problem I have updated this file after the original post and ...
1
vote
0
answers
79
views
How do you get the Simplify function to completely simplify an inequality in Mathematica?
I am working on testing whether a function lies in a given range. Somehow, the function Simplify does not provide the correct (obvious) answer. Why is that ?
The main function corresponds to the ...
3
votes
2
answers
156
views
C++ How to simplify member functions that only differ in function call
I need to create 10 functions that are very long and identical in every way except for a single line of code in each function. This single line of code is a function call.
Is there a way to condense ...
4
votes
1
answer
139
views
How to simplify huge arithmetic expression?
I have a huge expression, something like this:
x49 + t49 + FUNC1(y49 + z49 + FUNC1(w49 + h49 + FUNC1(v49) + RET(v49, t49, z49) + movr[50] + m1[50]) + RET(w49 + h49 + FUNC1(v49) + RET(v49, t49, z49) + ...
0
votes
2
answers
51
views
Simplifying if(condition): return True to one line return statement changes results in Python
I do not understand why the two methods written below perform differently. Any insights into why the simplified statement in xyz_there() fails for this test case would be appreciated!
str = "...
-2
votes
1
answer
83
views
How to simplify this code in Javascript via function chaining?
I would to know how to simplify theses function calls by chaining them. Is there a way to chain forEach, push, destructuring array and map.
let selectorsForLoader = ['a', 'b'];
let loadingElements = ...
0
votes
2
answers
278
views
How to simplify this Rust code with nested `match` with guards returning `Result`s?
Is there a simpler way of writing this Rust code? For full context, see this PR.
impl FromArgValue for FlakeRef {
fn from_arg_value(s: &str) -> std::result::Result<FlakeRef, String> {
...
0
votes
1
answer
66
views
The problem with load .glb model in Simplify Modifator (three.js)
I'm trying to use Simplify Modifator, but every time I upload my .glb file I've tried dozens of them, I've also tried different models directly from the examples in three.js, and none of them work ...
1
vote
1
answer
130
views
How do I shift my [ngClass] conditions into a separate ts file as a reusable code across all components, instead of repeating it in every html file?
Currently I have my codes working. However, my [ngClass] conditions are very bulky. Having it repeated in many components in the html makes it difficult to maintain if any change is needed and makes ...
-2
votes
3
answers
211
views
How to simplify c++ constructor that just copies the parameters to its fields?
This is what I have:
class Vector3 {
private:
float x;
float y;
float z;
public:
Vector3(float x = 0, float y = 0, float z = 0) {
this->x = x;
...
1
vote
1
answer
139
views
How can I provide a variable percentage to mapshaper via the cli?
I need to simplify Admin 0 – Details > map units 10m NaturalEarthData ( file ). It is 25mb and I would like to get it down to around 1mb or less. This should be easy because the 110m near-...
0
votes
1
answer
155
views
can Maple simplify a Fourier series?
how can I use Maple to simplify
sum ( sin(n*t) / n, n=1..infinity)
to (Pi-t)/2 for 0 < t < 2*Pi ?
Thanks for your help
Pavel
I tried
assume (0 < t and t < 2*Pi):
s := sum ( sin(n*t)/n, n=1....
0
votes
2
answers
104
views
How to display properly monomial in python with sympy
I've an expression that after simplify method looks like this:
5*y**3/2
I would like to see expression in this view:
(5/2) * y ** 3
but I have no idea how to do this.
Thanks in advance.
1
vote
2
answers
931
views
Simplifying code for placing ships in Battleship game in Python and conducting Unit Testing
I am currently working on a class project to build the game Battleship in Python. Another user here graciously helped me understand the coding for my board, and now I have come to the step to ...
-1
votes
1
answer
93
views
Can I shorten this very long elif chain?
if p11 == "+":
loc = 11
elif p12 == "+":
loc = 12
elif p13 == "+":
loc = 13
elif p14 == "+":
loc = 14
elif p15 == "+":
loc = 15
I ...
0
votes
1
answer
105
views
Is there a better equivalent to "1 - pow(1 - x, y)"?
In graphics programming I often deal with values in the 0-1 range and perform various mathematical operations on them, one being raising values to a power to achieve an exponential effect:
Math.pow(0....
0
votes
1
answer
187
views
Is there an easy way to comment out / silence a code cell in Python/Colab?
enter image description here
I am wondering if there is an easier way to do exactly this. I often have code that is theoretically useful for later if I run into a problem, but currently do not want it ...
0
votes
1
answer
174
views
How can I extract all the coefficients of a linear equation?
I have a linear equation in two variables that I am simplifying using simplify from sympy and I want to extract all the coefficients of the equation. This is what I have for the coefficients of x and ...
0
votes
1
answer
258
views
Simplifying nested if statements in Python
I am working on a JSON database that stores multiple choice questions. I defined a function that takes some arguments that are NOT obligatory in order to fetch questions based on your needs (...
0
votes
1
answer
70
views
Simplify two functions with same functionalities?
I have two functions that do the same thing, but are used differently.
I currently have a popup that is triggered on actions based on device. On desktop, if the mouse leaves the page, it triggers the ...
1
vote
1
answer
1k
views
Karnaugh map & Quine McCluskey
I would like to know if the same answer should be obtained when simplifying an expression using a karnaugh map and the mccluskey method. I guess that it does but I would prefer to get a confirmation.
0
votes
1
answer
2k
views
SQL insert statement - FILL null values for all columns except some
I have an insert statement where I only need to fill 15 columns out of 70 - and all the other columns can remain NULL. I would like to find a way to write this statement in a shorter matter without ...
0
votes
1
answer
43
views
How to create a function from the 3 I have written
These 3 functions I have written are all very similar, they all do the scatterplot of 2 variables. Is it possible to create a single function with parameters, instead of having to repeat 3 times ...