text:
# Module 7: Further functions

• how can we use functions to build abstractions?
• what is pass-by-reference?
• what is visibility vs scope?

We started out in this course by writing functions with very simple control flow, as in these examples from labs 2 and 3:

These flowcharts show a very simple control flow: a sequential control flow in which statements are executed, one after the other, until the function is complete. We then added to our function design toolkit by introducing branching or conditional control flow. This used if statements to choose between two alternate possibilities, allowing us to write more interesting functions like onLine() from lab 4:

Then we started designing loops, which also employ conditions but use them to perform actions zero or more times rather than zero times or once. Loops allow us to tackle example problems in places like Project Euler or, in fact, assignment 3! Loops are also going to be a very important part of our remaining labs, and were included in lab 4:

Now we will step back and think a bit more broadly about the functions we’ve been writing. In particular, we will think about how we use functions to build abstractions that help us solve problems.

## Call graphs

A graph (in this sense of the word) has nodes and edges. We have already used flowcharts, in which the nodes are process boxes or decision diamonds and the edges represent control flow. Now, however, we can a new kind of graph to our repertoire: the call graph. A call graph shows us how functions call other functions. We can layer this kind of information on top of function flowcharts, as shown here:

However, at a more abstract level (leaving out the details of what happens inside each function), we can concentrate on the more abstract call graph:

At each of these function calls, arguments from the function call are passed into parameters. So far in the course, we have seen these arguments be passed by value: the values of the arguments are copied into the parameters so that parameters are independent of the values they were initialized by:

Now, however, we will see a new way of passing arguments: by reference.

## Pass-by-reference

Sometimes we don’t want this independence of parameters from the values that are used to initialize them. Instead of passing arguments by value, in which copies get made of all the values, we want to share our variables with a function and give permission for that function to use our variables directly. In C++, this is done using pass-by-reference. In class, we discussed a weather function that would retrieve the current weather from a set of sensors. That function will measure many things and need to “return” many values, but so far we’ve only seen how to return a single value. Using pass-by-reference, however, we can construct the following sort of call:

In this call, the main function calls weather and gives weather permission to modify some local variables of main. When the weather function takes its measurements, instead of returning them to main, it can write the values directly into those main variables that it was passed references to.

The syntax for C++ pass-by-references requires an additional ampersand (&) between a parameter’s type and name:

/**
* Report the current weather.
*
* @param[out]   temperature    the current temperature [degrees C]
* @param[out]   humidity       the current humidity [percent]
*                              @post humidity >= 0 and humidity <= 100
* @param[out]   windSpeed      the current wind speed [km/h]
*/
void weather(double& temperature, double& humidity, double& windSpeed);

/* ... */

void weather(double& temperature, double& humidity, double& windSpeed)
{
temperature = /* ... */;
humidity = /* ... */;
windSpeed = /* ... */;
}

Apart from this ampersand, the declaration and definition of the weather function look just like something we could’ve written before. What is different now is the meaning (semantics): instead of copying a value into each parameter of weather, we are giving weather access to the local variables of main. An important difference in the call to a pass-by-reference function is that we can only pass variables, not literal values. This is because we are no longer passing values, we’re passing references to variables… so we need variables to have references to!

We can use pass-by-reference to implement lots of functions that would’ve been impossible with the tools we had before, e.g.:

void swap(int& x, int& y)
{
int temp = x;
x = y;
y = temp;
}

## Design with functions

Now that we have some notion of how functions work, let’s talk about how to use them in designed solutions to problems. We have seen how functions can help up build up high-level abstractions from lower-level ones, e.g., a function that makes a robot drive forwards will delegate some of its work to lower-level functions that read sensors or turn on the power on motor wheels. This is a bottom-up approach to implementation. Now, however, let’s look at how we can take a top-down approach to problem solving by dividing it into smaller pieces (divide and conquer). This is a common approach in many Engineering disciplines, and it is quite effective in programming.

### Procedural decomposition

The top-down approach to procedural decomposition is:

1. Divide the problem into independent sub-problems that are easier to solve.
2. Start with a high-level solution to the problem — many steps may be abstract (i.e., some of the implementation details remain unspecified).
3. Gradually refine solution into an concrete solution (i.e., algorithm) by adding detail.

#### Example

Problem: write a function to find the total mass of a batch of (identical) washers.

##### Analysis:

A washer is a doughnut-shaped disc of metal of uniform thickness whose mass is a product of its volume and its density. The mass of a batch would simply be the mass of an individual washer times the number of washers in the batch.

##### Decomposition:

Find the mass of a batch of washers:

1. Find the mass, $m$, of an individual washer
2. Batch mass = $n \times w$

Now we refine the first step:

1. Find the mass, $m$, of an individual washer
1. Find the washer’s area, $A$
2. Find the washer’s volume, $V = A \times d$ (depth)
3. $m = V \times D$ (density)
2. Batch mass = $n \times m$

We can also refine the first step of this refined step:

1. Find the mass, $m$, of an individual washer
1. Find the washer’s area, $A$
1. Find the area of the outer circle, $A_0$
2. Find the area of the inner circle, $A_1$
3. $A = A_0 - A_1$
2. Find the washer’s volume, $V = A \times d$ (depth)
3. $m = V \times D$ (density)
2. Batch mass = $n \times m$

Now, it seems like there’s still another refinement to be made:

To find the area of a circle: $A = \pi r^2$

Each of the reusable steps in our solution that involves creating an abstraction (e.g., talking about total volume rather than the lower-level details of inner/outer radii and depth) is a candidates to be a function, even if a simple one. Some examples of function declarations that we talked about in class include:

/**
* Calculates the volume of a washer-shaped object.
*
* @param     r1     radius of the washer
* @param     r2     radius of the washer's hole [same linear unit as r1]
*
* @pre r2 > 0, r2 < r1
*
* @returns   total volume [same linear unit cubed]
*/
double washerVolume(double r1, double r2, double depth);

/**
* Calculates the area of a circle.
*
*
* @returns the area of the circle [units of radius squared]
*/

Exercise: write definitions for these and whatever other functions are required to implement a complete solution to the above problem.

### Delegation

This is an exercise in delegation. Each function delegates most of its work to an assistant function. All the inputs (arguments) needed to carry out the whole problem are sent to the topmost function. It can simply passes four of its parameters over to a washerMass function, then multiplies the mass returned by that function by the count in order to calculate the mass of the entire batch. This is a very simple problem and the amount of delegation involved is fairly extreme in that, once each function delegates, it has very little left to do. Nevertheless, it illustrates the principle very well.

In practice, functions run from one line to hundreds of lines in length, with many functions being fewer than 20 lines. Once functions exceed 50–100 lines, it can be a sign that there are opportunities to break it into smaller, more reusable, pieces.

## Visibility

We have previously talked about variable scope, but what do we do when there are multiple variables in scope that have the same name? For example, in the following code:

int x;

void foo(int y)
{
if (y > 0)
{
int x = 17;

while (x > y)
{
int z = y / 2;
x -= z;
}
}
}

which x variable is referenced by the statement x -= z? The answer is, when we have a choice of declarations that we might be referring to, we choose the most local one.

## Exercises

1. Write a function that will convert 2D cartesian co-ordinates (i.e., $(x,y)$ co-ordinates) into polar co-ordinates (i.e., $(r,\theta)$).
2. Write a function that will compute the roots of a quadratic expression, dealing with all special cases (i.e., $a=0$ and $b^2 < 4ac$).
3. Using getNumberFromUser() from the examples page, write a function that will input an $(x,y,z)$ co-ordinate from a user and make it available to the function that called it.

(c) 2009–2016 Michael Bruce-Lockhart, Theo Norvell, Dennis Peters and Jonathan Anderson. Licensed under a Creative Commons Attribution–Noncommercial–Share-Alike 2.5 Canada License. Permissions beyond the scope of this license may be available at theteachingmachine.org.


text:
# As a level 4 halfling hexblade pact of the blade warlock, what are my options for high damage per round?

I play a halfling hexblade pact of the blade warlock. I recently learned exactly how hexblade/pact of the blade interaction work in this this question. I figured out that I can have 2 weapons that benefit from the hex warrior feature. I also read everywhere that using a 2 handed weapon is better then dual wielding, but since I am a halfling I get disadvantage on 2 handed weapons (at least on heavy weapons but almost all 2 handed weapons are heavy).

My question is:

What weapons would be best for a high DPR on a halfling?

• a 2 hander even though I have disadvantage on it (1d12 but disadvantage).

• 2 light weapons for dual wielding (2x 1d6).

• 1 versatile weapon (1d8 but 1d10 versatile).

I would also like to know how this damage is compared to eldrich blast.

I currently am only looking for the best way to play at this level, sugestions for higher levels are always welcome.

All weapons would use the same modifier (CHA +3) because I can make them with the pact of the blade or have them as a pact weapon (for dual wield).

I do not have any bonuses from feats or eldritch invocations, I used them for roleplay aspects.

# Two-Weapon Fighting is best for DPR

TL;DR: The Heavy weapon causes the Halfling to miss too often, losing a lot of DPR and the damage from the second attack of Two-Weapon Fighting is greater than the damage gained from the higher damage die. Eldritch Blast is a very poor option before level 5 if you don't have the Agonizing Blast invocation.

## Heavy vs Versatile

First let's compare Heavy weapons with Versatile weapons wielded in 2 hands. A Heavy weapon's 1d12, on average, deals 1 more damage on a normal hit and 2 more damage on a critical hit when compared to a Versatile weapon's 1d10. So, if we multiply these damages by hit chance and crit chance, we can arrive at how much damage a Heavy weapon deals over a Versatile weapon (for a Medium creature).

Regular Hit Formula: $$\HitChance=\frac{(20-(Target AC - Attack Bonus))}{20}\$$

$$\begin{array}{c|c} \text{Target AC}&\text{Damage Difference} \\ \hline 10&0.85 \\ 11&0.8 \\ 12&0.75 \\ 13&0.7 \\ 14&0.65 \\ 15&0.6 \\ 16&0.55 \\ 17&0.5 \\ 18&0.45 \\ 19&0.4 \\ 20&0.35 \\ 21&0.3 \\ 22&0.25 \\ 23&0.2 \\ 24&0.15 \\ 25+&0.1 \\ \end{array}$$

Formula: $$\Regular Damage+Critical Damage=1*HitChance+2*0.05 \$$

However, Halfling are small, so they have disadvantage on checks with Heavy weapons. This means there is a 95% chance that a critical hit is not one and a chance that a hit becomes a miss. This means the entire damage of the attack (or extra die) is lost, and that damage loss is shown in the following chart:

$$\begin{array}{c|c} \text{Target AC}&\text{Loss from Disadv} \\ \hline 10&1.83 \\ 11&2.09 \\ 12&2.30 \\ 13&2.47 \\ 14&2.59 \\ 15&2.66 \\ 16&2.68 \\ 17&2.66 \\ 18&2.59 \\ 19&2.47 \\ 20&2.30 \\ 21&2.09 \\ 22&1.83 \\ 23&1.52 \\ 24&1.16 \\ 25+&0.76 \\ \end{array}$$

Formula: $$\Regular Loss+Critical Loss=9.5*HitChance*(1-HitChance)+6.5*0.05*0.95 \$$

Since at every relevant AC, the loss is greater than the damage gained from the higher damage die, all other things equal the Versatile weapon is better than the Heavy weapon for the Halfling.

## Versatile vs Two-Weapon Fighting

Now that we know Versatile is better than Heavy at all Armor Classes, let's compare Versatile and Two-Weapon Fighting. First consider only the first attack. A Versatile weapon's 1d10, on average, will deal 2 more damage on a normal hit and 4 more damage on a critical hit when compared to a Light weapon's 1d6. We follow the same procedure as with Heavy vs Versatile and see the damage based on target Armor Class.

$$\begin{array}{c|c} \text{Target AC}&\text{Damage Difference} \\ \hline 10&1.7 \\ 11&1.6 \\ 12&1.5 \\ 13&1.4 \\ 14&1.3 \\ 15&1.2 \\ 16&1.1 \\ 17&1.0 \\ 18&0.9 \\ 19&0.8 \\ 20&0.7 \\ 21&0.6 \\ 22&0.5 \\ 23&0.4 \\ 24&0.3 \\ 25+&0.2 \\ \end{array}$$

Formula: $$\Regular Damage+Critical Damage=2*HitChance+4*0.05 \$$

However, When using a Light weapon, the warlock can use Two-Weapon Fighting to get another attack. This other attack doesn't add the ability modifier, but still increases damage by an average of 3.5 on a hit and 7 on a crit. Here is the damage from second attack modified by hit and crit chance:

$$\begin{array}{c|c} \text{Target AC}&\text{Second Attack} \\ \hline 10&2.98 \\ 11&2.8 \\ 12&2.63 \\ 13&2.45 \\ 14&2.28 \\ 15&2.15 \\ 16&1.93 \\ 17&1.75 \\ 18&1.58 \\ 19&1.4 \\ 20&1.23 \\ 21&1.05 \\ 22&0.88 \\ 23&0.7 \\ 24&0.53 \\ 25+&0.35 \\ \end{array}$$

Formula: $$\Damage=3.5*HitChance+7*0.05 \$$

Since, at every relevant AC, the damage from the second attack is greater than the damage gained from the higher damage die, all other things equal Two-Weapon Fighting is better than the Versatile weapon.

## Eldritch Blast?

Eldritch Blast is even worse than a Versatile weapon at level 4. Since the warlock does not add Charisma modifier to damage from eldritch blast, the spell loses 3 damage on a regular and critical hit when compared to the Versatile weapon. Here is the Damage Difference between 1 attack of a Versatile weapon and an eldritch blast beam:

$$\begin{array}{c|c} \text{Target AC}&\text{Damage Difference} \\ \hline 10&2.4 \\ 11&2.25 \\ 12&2.1 \\ 13&1.95 \\ 14&1.8 \\ 15&1.65 \\ 16&1.5 \\ 17&1.35 \\ 18&1.2 \\ 19&1.05 \\ 20&0.9 \\ 21&0.75 \\ 22&0.6 \\ 23&0.45 \\ 24&0.3 \\ 25+&0.15 \\ \end{array}$$

Formula: $$\Regular Damage+Critical Damage=3*HitChance+0*0.05 \$$

Since the Versatile weapon is already established as worse for DPR than Two-Weapon Fighting, eldritch blast also falls short (although it does beat out Heavy weapons at low Armor Classes).

## Summary Table

I've been doing comparisons throughout this answer to show how flexible math can be for figuring out differences between a few different options saving some time on doing the entire damage calculation. But here is the entire damage calculation for the sake of completeness:

$$\begin{array}{c|c|c|c} \text{Target AC}&\text{Heavy}&\text{Versatile}&\text{Two-Weapon}&\text{Eldritch Blast} \\ \hline \text{10}&6.41&7.08&8.35&4.68 \\ \text{11}&5.67&6.65&7.85&4.4 \\ \text{12}&4.98&6.23&7.35&4.13 \\ \text{13}&4.34&5.8&6.85&3.85 \\ \text{14}&3.75&5.38&6.35&3.58 \\ \text{15}&3.20&4.95&5.85&3.3 \\ \text{16}&2.7&4.53&5.35&3.03 \\ \text{17}&2.25&4.1&4.85&2.75 \\ \text{18}&1.85&3.68&4.35&2.48 \\ \text{19}&1.49&3.25&3.85&2.2 \\ \text{20}&1.18&2.83&3.35&1.93 \\ \text{21}&0.92&2.4&2.85&1.65 \\ \text{22}&0.71&1.98&2.35&1.38 \\ \text{23}&0.54&1.55&1.85&1.1 \\ \text{24}&0.42&1.13&1.35&0.83 \\ \text{25+}&0.35&0.7&0.85&0.55 \\ \end{array}$$

Formula: $$\Regular Damage+Critical Damage+Second Hit+Second Damage=\frac{Damage Die+1+2*Modifier}{2}*HitChance+2*\frac{DamageDie+1}{2}*0.05+\frac{Damage Die+1}{2}*HitChance+2*\frac{DamageDie+1}{2} \$$

note: eldritch blast consists of only a second attack in this formula and the Heavy column has Disadvantage factored in (square HitChance)

## Level 5

Level 5 changes things a lot. Eldritch blast gets a second beam, your proficiency bonus increases, and you get access to Thirsting Blade and Eldritch Smite as Eldritch Invocation options if you want to choose them. Since you said you choose Invocations for roleplay purposes, I'm going to assume you did not choose a combat Invocation for this table (if you want to know how to maximize the functionality of one of these invocations, I suggest you ask a new question). Below find the adjusted table for level 5:

$$\begin{array}{c|c|c|c} \text{Target AC}&\text{Heavy}&\text{Versatile}&\text{Two-Weapon}&\text{Eldritch Blast} \\ \hline \text{10}&7.19&7.5&8.85&9.9 \\ \text{11}&6.41&7.08&8.35&9.35 \\ \text{12}&5.67&6.65&7.85&8.8 \\ \text{13}&4.98&6.23&7.35&8.25 \\ \text{14}&4.34&5.8&6.85&7.7 \\ \text{15}&3.75&5.38&6.35&7.15 \\ \text{16}&3.20&4.95&5.85&6.6 \\ \text{17}&2.7&4.53&5.35&6.05 \\ \text{18}&2.25&4.1&4.855&5.5 \\ \text{19}&1.85&3.68&4.35&4.95 \\ \text{20}&1.49&3.25&3.85&4.4 \\ \text{21}&1.18&2.83&3.35&3.85 \\ \text{22}&0.92&2.4&2.85&3.3 \\ \text{23}&0.71&1.98&2.35&2.75 \\ \text{24}&0.54&1.55&1.85&2.2 \\ \text{25}&0.42&1.13&1.35&1.65 \\ \text{26+}&0.35&0.7&0.85&1.1 \\ \end{array}$$

Note: the formulae are the same as for the level 4 table, but the eldritch blast column is doubled since there are now two beams

As you can see, without a combat invocation, eldritch blast surpasses the weapon options at level 5 even without Agonizing Blast.

• Now that's detailed; +1, and a tip of the cap. (But weren't you tempted to lead with "eldritch blast is best for DPR after level 5" ) – KorvinStarmast Sep 25 '18 at 1:04
• @KorvinStarmast Thirsting blade makes the melee options more competitive. It's hard to know what Invocation the OP will choose since we don't know the "roleplay" choices he would make. I mostly put the level 5 table in to hint that a melee Warlock needs Thirsting Blade or Eldritch Smite to keep up. If someone wants to ask another question about which option is best with Thirsting Blade, I'd be glad to answer. – David Coffron Sep 25 '18 at 1:08
• The wide 2-row tables don't display well and the text overlaps with the related questions/HNQ in the sidebar. You might want to make them vertical 2-column tables instead. – V2Blast Sep 25 '18 at 1:47
• @V2Blast Will do. They displayed well when the answer was below the text, but will fix – David Coffron Sep 25 '18 at 3:09

# 2 Light Weapons would normally be best

### Comparing the weapon options

If we take an enemy with an AC of 15, we can directly compare the average damage of each of the options that you listed:

1. A heavy weapon (1d12+3 damage) with disadvantage on attack rolls

• For this weapon, the average damage on a hit is 9.5 and on a critical hit you do an average of 16.
• However, given the disadvantage, you only have a 30% chance of a normal hit and only a 0.25% of a critical hit.
• Thus the average damage in a round is only 2.89
2. For a versatile weapon, wielded in 2 hands (1d10+3 damage)
• The average damage on a hit is 8.5 and on a critical hit it is 14
• The chance of a regular hit is 50% and the chance of a critical hit is 5%
• Thus the average damage in a round is 4.95
3. For dual wielding 2 light weapons (1d6+3 damage and 1d6 damage for the offhand)
• The average damage with you main weapon is 6.5 for a hit and 10 for a critical hit
• The average damage with your offhand is 3.5 for a hit and 7 for a critical hit
• For both attacks, the chance of a regular hit is 50% and the chance of a critical hit is 5%
• Thus the average damage is 3.75 + 2.1 which gets you 5.85

### Other Considerations

There are a couple of other points worth considering when evaluating the weapon choices

Disadvantage: - If the enemy has a lower AC then the impact of the disadvantage from the heavy weapon becomes lower, however 2 light weapons are still better - If the enemy has a higher AC, the impact of disadvantage becomes more pronounced and the 2-handed weapon becomes an even worse option - However, if you have disadvantage on your attack for another reason, then there is no penalty to a 2-handed weapon and this becomes the best option.

Bonus Action: - While the 2 light weapons produce the highest DPR, this does also use your Bonus Action. - If there is another use that you regularly have for your BA, then the versatil weapon becomes a more attractive option.

Comparison to Eldritch Blast: - Assuming that you do not have Agonising Blast, the average damage per round from EB is worse than for the versatile weapon at only 3.3 - If you do have Agonising Blast, then the damage for EB becomes the same as for the versatile weapon (1d10+3) although obviously the range on EB is much higher!

Hope that helps!

# With no Invocations, Two Shortswords are best

The rest of this post will detail the effect if you do take Invocations to improve DPR. If you don't, then all you need to know is that no matter your damage modifier, 2d6 is always going to deal more damage than 1d10, so regardless of damage modifiers your damage output will always be higher with two Shortswords than with one Longsword.

Having said that, Warlocks get 8 invocations in total, gain them as they level, and are permitted to swap one-per-level as they level up. So since your damage output will strongly depend on having one or more of those Invocations active, I strongly recommend you take them.

For the purposes of this post, I'm going to mostly ignore the effect of Hexblade's Curse. It has substantial implications for your overall damage output, but it's also limited to a single target per short rest, meaning you can't count on it taking effect on every single creature you fight. I'll factor it in for level 14 onwards, since at that point, you gain the ability to transfer it between creatures, but until that point, I'm going to treat it as though it doesn't exist.

### Before Thirsting Blade Invocation (level 5), use two Shortswords

This is your damage output potential for each style:

• Before level 5's Thirsting Blade:
• Two Shortswords: 1d6 + 3 (Attack Action) + 1d6 (Bonus Action) == 2d6 + 3 == 10
• One Longsword: 1d10 + 3 (Attack Action) == 8.5

The downside is the use of that Bonus Action, which you may have preferred to use on a Bonus-Action spell. If that's the case, then the longsword will be better in terms of action economy. But for pure damage, the Shortsword is better.

### With Thirsting Blade Invocation (level 5), use a Longsword

The damage numbers shuffle around to favor a Longsword in this range. We'll also assume you have either a +CHA modifier of 4 or 5.

• Two Shortswords: 1d6 + 4 (Attack Action) + 1d6 + 4 (Thirsting Blade) + 1d6 (Bonus Action) == 3d6 + 8 == 18.5
• One Longsword: 1d10 + 4 (Attack Action) + 1d10 + 4 (Thirsting Blade) == 2d10 + 8 == 19

### With Lifedrinker Invocation (level 12), use a Longsword

• With Lifedrinker:
• Two Shortswords (Pact Weapon main, Hex weapon offhand): 1d6 + 10 (Attack Action) + 1d6 + 10 (Thirsting Blade) + 1d6 == 3d6 + 20 == 30.5
• One Longsword: 1d10 + 10 (Attack Action) + 1d10 + 10 (Thirsting Blade) == 2d10 + 20 == 31

### With Master of Hexes Hexblade feature (level 14), use Two Shortswords

Since you can now much more reliably depend on your hex being applied to more than one creature, it's now appropriate to factor it in in a more general scenario. This feature dramatically improves your overall damage output based on your level:

• Two Shortswords: 1d6 + 10 + PROF (Attack Action) + 1d6 + 10 + PROF (Thirsting Blade) + 1d6 + PROF (Bonus Action) == 3d6 + 20 + 3xPROF == 30.5 + 3xPROF
• At level 14, with PROF == 5, this becomes 45.5
• At level 17, with PROF == 6, this becomes 48.5
• One Longsword: 1d10 + 10 + PROF (Attack Action) + 1d10 + 10 + PROF (Thirsting Blade) == 2d10 + 20 + 2xPROF == 31 + 2xPROF
• At level 14, with PROF = 5, this becomes 41
• At level 17, with PROF = 6, this becomes 43

### If you can always count on your Hexblade's Curse being active (or only care about DPR while it is active), always use Two Shortswords

In the scenarios where Longsword is better than two Shortswords, the benefit from Hexblade's Curse will cause the DPR of the Shortswords to exceed the damage of the Longsword (which we can observe with trivial calculations).

• @András Yeah. I've fixed it. – Xirema Sep 24 '18 at 15:46
• @András Small creatures can use Versatile weapons. The issue that you may be thinking of is that they have difficulty using Two Handed melee weapons, since all such weapons are Heavy. But it's the Heavy quality that causes the problem: not the use of two hands. (For example, Small creatures can use Light Crossbows without disadvantage, but not Longbows). – Gandalfmeansme Sep 24 '18 at 15:53
• Combat usually is shorter than 3 rounds, the better optimized you are, the shorter. Starting Hexblade's Curse is a bonus action, it takes away one of your 3 off-hand attacks. Monsters die even more frequently, the 3 rounds are from the start of the encounter until the last monster dies. In practice you lose more than one-third of all off-hand attacks. – András Sep 24 '18 at 15:58
• Note that the weapon chosen with Hex Warrior, while it gets to use Cha for attack and damage, is not a pact weapon, so invocations that improve pact weapons don’t improve that weapon. Specifically, lifedrinker only applies to the weapon that is the actual pact weapon. – KRyan Sep 24 '18 at 16:57
• @KRyan Good point, I'll fix the post. – Xirema Sep 24 '18 at 17:06

format: plain


text:
# Posts Tagged ‘ matlab ’

## MatLab, SAS, STATA, SPSS, Excel users: Try R, damn it!

July 2, 2012
By

Due to my work with a multitude of statistical packages in my career I may be able to evaluate a lot of them. I’ve first used Excel for my calculations as most of the normal users do. I like the idea behind a spreadsheet and the combination of data and click-to-do functions. Nevertheless I’ve often

## speed of R, C, &tc.

February 2, 2012
By

My Paris colleague (and fellow-runner) Aurélien Garivier has produced an interesting comparison of 4 (or 6 if you consider scilab and octave as different from matlab) computer languages in terms of speed for producing the MLE in a hidden Markov model, using EM and the Baum-Welch algorithms. His conclusions are that matlab is a lot

September 4, 2011
By

When I received this book, Handbook of fitting statistical distributions with R, by Z. Karian and E.J. Dudewicz,  from/for the Short Book Reviews section of the International Statistical Review, I was obviously impressed by its size (around 1700 pages and 3 kilos…). From briefly glancing at the table of contents, and the list of standard

## Seriously … why don’t math classes use computers?…

August 31, 2011
By

Seriously … why don’t math classes use computers? Excel, simple Python scripts, Mathematica / Sage, everything beyond the TI-83. Kids could be creating totally sweet visuals instead of cribbing formulae. And thinking instead of copying. I can sa...

## Nomograms everywhere!

August 30, 2011
By

At useR!, Jonty Rougier talked about nomograms, a once popular visualisation that has fallen by the wayside with the rise of computers. I’d seen a few before, but hadn’t understood how they worked or why you’d want to use them. Anyway, since that talk I’ve been digging around in biology books from the 60s and

## Friday Function: nclass

May 6, 2011
By

When you draw a histogram, an important question is “how many bar should I draw?”. This should inspire an indignant response. You didn’t become a programmer to answer questions, did you? No. The whole point of programming is to let your computer do your thinking for you, giving you more time to watch videos of

## supercalifragilisticexpialidocious = 1

April 21, 2011
By

I notice that the latest version of R has upped the maximum length of variable names from 256 characters to a whopping 10 000! (See ?name.) It makes the 63 character limit in MATLAB look rather pitiful by comparison. Come on MathWorks! Let’s have the ability to be stupidly verbose in our variable naming! Tagged:

## Converting MATLAB and R date and time values

February 20, 2011
By

For some unknown reason, MATLAB codes its date/time values as the number of elapsed days starting from January 1 in the year 0000. R uses the equally arbitrary, but much more widespread POSIX/Unix epoch as a reference for time keeping, so that R’...

## Software tools for data analysis – an overview

February 19, 2011
By

by Szilard Pafka Discussions on various software tools (C, C++, Perl, Python, Unix shell, R, Matlab, SAS, SPSS, Excel, databases, Hadoop etc.) used in data analysis. Szilard Pafka (founder and co-organizer of the Los Angeles R users group) presents an … Continue reading →

## When 1 * x != x

January 16, 2011
By
$When 1 * x != x$

Trying to dimly recall things from my maths degree, it seems that in most contexts the whole point of the number one is that it is a multiplicative identity. That is, for any x in your set, 1 * x is equal to x. It turns out that when you move to floating point numbers,


text:
# The set of all vertices, such that each vertex in the set has a path to exactly $k$ vertices

I need to find algorithms for both undirected and directed graphs, with no assumption on them being connected. Also the algorithms must be $O(V+E)$, where the undirected one should not depend on $k$.

I have ideas for both, i'm just not very sure about the directed version, because I'm not sure on how to approach the correctness proof.

For the directed version, I thought about finding all the SCC's with two DFS runs, and then running a topological sort on the graph created by representatives from each SCC. Afterwards, i'll flip the edges and start a DFS from the end vertex. For every SCC node I visit i'll increment a counter by the number of nodes in the SCC I visited. If while vising a SCC node the counter shows $k+1$ nodes, all the nodes in the SCC will be added to the set. At this point the algorithm will go back as though we reached a leaf.

For the undirected version, I can just do run a BFS/DFS for every disconnected component to find all the connected components. If a connected component has exactly k+1 nodes, then all the nodes in that component belong to the set.

Any help regarding the directed version will be great, thanks!

• Prove that in the directed case you need to have an SCC of size exactly $k+1$ as otherwise you would have two vertices with different sized reachability set. – Pål GD Apr 26 '15 at 5:06


text:
# Members & Guests

## Dr. David González Álvaro

### Researcher

Université de Fribourg

E-mail: david.gonzalezalvaro(at)unifr.ch
Telephone: +41 26 300-9199
Homepage: http://homeweb.unifr.ch/gonzalda/pub/

## Publications within SPP2026

In this paper we establish stability of the Ricci de Turck flow near Ricci-flat metrics with isolated conical singularities. More precisely, we construct a Ricci de Turck flow which starts sufficiently close to a Ricci-flat metric with isolated conical singularities and converges to a singular Ricci-flat metric under an assumption of integrability, linear and tangential stability. We provide a characterization of conical singularities satisfying tangential stability and discuss examples where the integrability condition is satisfied.

 Pages 46 Link to preprint version
• 1