text:
.donation-modal {
  font-size: 1.2rem;
}

.donation-modal p {
  width: 90%;
  margin-left: auto;
  margin-right: auto;
}

.donation-modal .modal-title {
  font-size: 1.2rem;
}

.donation-form {
  display: flex;
  flex-direction: column;
  width:80%;
  justify-content: center;
  margin: 0 auto;
  height: 300px;
}

#donate-amount-panel ul {
  list-style: none;
  display: flex;
  margin-left: 0px;
}

#donate-amount-panel li {
  flex: 0.20;
  display: flex;
  justify-content: center;
  align-items: center;
}

#donate-amount-panel a {
  width: calc(100% - 20px);
  height: 75px;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 2px solid #006400;
}

#donate-amount-panel a:hover, #donate-amount-panel a:focus, #donate-amount-panel a.active {
  text-decoration: none;
  color: white;
  background-color: #006400;
  font-weight: bold;
}

.donation-elements {
  display: flex;
  height: 100%;
  flex-direction: column;
  justify-content: space-evenly;
}

#donation-completion-body {
  display: flex;
  justify-content: center;
  align-items: center;
}

.donation-completion-buttons {
  display: flex;
  justify-content: flex-end;
}

.donation-completion-buttons button {
  margin: 0 10px;
}

.donation-email-container {
  width: 80%;
  margin: 0 auto;
}

.donation-email-container label {
  display: flex;
  flex-direction: column;
}

.donation-email-container input {
  color: #006400;
  font-weight: normal;
  border: none;
}

.maybe-later-container {
  width: 80%;
  margin: 50px auto 0;
  display: flex;
  justify-content: center;
}

.maybe-later-container a {
  font-size: 18px;
}

.maybe-later-container a:hover {
  text-decoration: none;
  font-size: 18px;
  cursor: pointer;
}


text:
#ifndef _LDAPErrorHandler_H
#define _LDAPErrorHandler_H

#include "LDAPAPI.h"
#include "Mapper.h"

//---- LDAPErrorHandler ----------------------------------------------------------
//! Handles LDAP Errors
class LDAPErrorHandler
{
public:
	enum eRetryState { eRetry, eIsInRetrySequence, eNoRetry };
	//--- constructors
	LDAPErrorHandler(Context &ctx, ParameterMapper *getter, ResultMapper *putter, String daName);
	virtual ~LDAPErrorHandler();

	// handle session error with message
	virtual void HandleSessionError(LDAP *ldap, String msg);

	// handle session error without disposing of LDAPErrorHandler  object
	static void HandleUnbindError(LDAP *ldap);

	// handle other error (general implementation)
	virtual void HandleError(String msg, Anything args = Anything(), String argDescr = "AdditionalInfo");

	// get last error description of the assiciated DAImpl
	// (returns false, if none was found)
	virtual bool GetError(Anything &error);

	ROAnything GetQueryParams();
	ROAnything GetConnectionParams();

	void PutQueryParams(Anything qp);
	void PutConnectionParams(Anything cp);

	//! Set ShouldRetry flag This flag is used when LDAPPooledConnections are used
	virtual void SetRetryState(eRetryState retryState);
	//! Query ShouldRetry flag
	virtual eRetryState GetRetryState();
	//! Set retry state when not in a retry sequence, otherwise don't set the retry state
	//! The two cases need to be distinguished because otherwise the connection handle would
	//! not be released in the case where the retry itself failes.
	virtual void SetShouldRetry();

	//! Clean up LDAPError and LDAPResultSlot in Context's tmp store
	virtual void CleanUp();

	//! Translate eRetryState into string
	String RetryStateAsString(eRetryState retryState);

	//! Is retry state set to eRetry ?
	bool IsRetry();

protected:
	Context &fCtx;
	ParameterMapper *fIn;
	ResultMapper *fOut;
	String fName;
	Anything fQueryParams, fConnectionParams;
	eRetryState fRetryState;

private:
	void WriteError(Anything &error);
	String WriteSysLog(Anything error, String &msg);
};

#endif

redpajama_set_name: RedPajamaGithub


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BusinessObjects.MDSubjects;
using Csla.Web.Mvc;
using BusinessObjects.Security;
using DalEf;

namespace AlphaWebCommodityBookkeeping.Areas.MDSubjects.Controllers
{
    public class EnumsEducationDegreeController : Csla.Web.Mvc.Controller
    {
        //
        // GET: /MDSubjects/EnumsEducationDegree/

        public ActionResult Index()
        {
            ViewData.Model = cMDSubjects_Enums_EducationDegree_List.GetcMDSubjects_Enums_EducationDegree_List();
            return View();
        }

        //
        // GET: /MDSubjects/EnumsEducationDegree/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /MDSubjects/EnumsEducationDegree/Create

        public ActionResult CreateAndEdit(int id)
        {
            cMDSubjects_Enums_EducationDegree obj;
            if (id > 0)
            {
                obj = cMDSubjects_Enums_EducationDegree.GetMDSubjects_Enums_EducationDegree(id);
            }
            else
            {
                obj = cMDSubjects_Enums_EducationDegree.NewMDSubjects_Enums_EducationDegree();
            }
            ViewData.Model = obj;
            return View();
        }

        //
        // POST: /MDSubjects/EnumsEducationDegree/Create

        [HttpPost]
        public ActionResult CreateAndEdit(int id, [Bind(Exclude = "EntityKeyData")]cMDSubjects_Enums_EducationDegree obj, FormCollection collection)
        {
            LoadProperty(obj, cMDSubjects_Enums_EducationDegree.IdProperty, id);
            if (collection["EntityKeyData"] != "")
            {
                byte[] enKey = Convert.FromBase64String(collection["EntityKeyData"]);
                LoadProperty(obj, cMDSubjects_Enums_EducationDegree.EntityKeyDataProperty, enKey);
            }

            obj.CompanyUsingServiceId = ((PTIdentity)Csla.ApplicationContext.User.Identity).CompanyId;
            if (obj.IsValid)
            {

                if (obj.Id > 0)
                {
                    if (SaveObject<cMDSubjects_Enums_EducationDegree>(obj, true))
                    {
                        return RedirectToAction("Index");
                    }
                    else
                    {
                        ViewData.Model = obj;
                        return View();
                    }
                }
                else
                {
                    if (SaveObject<cMDSubjects_Enums_EducationDegree>(obj, false))
                    {
                        return RedirectToAction("Index");
                    }
                    else
                    {
                        ViewData.Model = obj;
                        return View();
                    }
                }
            }
            else
            {
                ViewData.Model = obj;
                return View();
            }
        }

        public ActionResult Odustani()
        {
            return RedirectToAction("Index");
        }

        //
        // GET: /MDSubjects/EnumsEducationDegree/Edit/5

        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /MDSubjects/EnumsEducationDegree/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, cMDSubjects_Enums_EducationDegree obj, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /MDSubjects/EnumsEducationDegree/Delete/5

        public ActionResult Delete(int id)
        {
            using (MDSubjectsEntities data = new MDSubjectsEntities())
            {
                var item = data.MDSubjects_Enums_EducationDegree.SingleOrDefault(p => p.Id == id);
                if (item != null)
                {
                    item.Inactive = true;

                    data.SaveChanges();
                }
            }
            return RedirectToAction("Index");
        }

        //
        // POST: /MDSubjects/EnumsEducationDegree/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        public ActionResult EnumsEducationDegreeGridPartial()
        {
            return PartialView("EnumsEducationDegreeGridPartial");
        }
    }
}


text:
package fasthttp

import (
	"errors"
	"syscall"
)

func isConnectionReset(err error) bool {
	return errors.Is(err, syscall.WSAECONNRESET)
}


text:
package com.appleframework.jms.jedis.consumer.cluster;

import com.appleframework.jms.core.consumer.IMessageConusmer;

/**
 * @author Cruise.Xu
 *
 */
public class TopicBytesMessageConsumer2 extends TopicBaseMessageConsumer {

	private IMessageConusmer<byte[]> messageConusmer;

	public void setMessageConusmer2(IMessageConusmer<byte[]> messageConusmer) {
		this.messageConusmer = messageConusmer;
	}

	@Override
	public void processMessage(byte[] message) {
		messageConusmer.onMessage(message);

	}

}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace EF6WhatsNew.Models
{
    public class Post
    {
        public int PkPostId { get; set; }
        public string Title { get; set; }
        public string Content { get; set; }
    }
}


text:
require 'spec_helper'

describe Puppet::Type.type(:dsc_xsqlhaendpoint) do

  let :dsc_xsqlhaendpoint do
    Puppet::Type.type(:dsc_xsqlhaendpoint).new(
      :name     => 'foo',
      :dsc_instancename => 'foo',
      :dsc_name => 'foo',
    )
  end

  it "should stringify normally" do
    expect(dsc_xsqlhaendpoint.to_s).to eq("Dsc_xsqlhaendpoint[foo]")
  end

  it 'should require that dsc_instancename is specified' do
    #dsc_xsqlhaendpoint[:dsc_instancename]
    expect { Puppet::Type.type(:dsc_xsqlhaendpoint).new(
      :name     => 'foo',
      :dsc_alloweduser => 'foo',
      :dsc_name => 'foo',
      :dsc_portnumber => 32,
    )}.to raise_error(Puppet::Error, /dsc_instancename is a required attribute/)
  end

  it 'should not accept array for dsc_instancename' do
    expect{dsc_xsqlhaendpoint[:dsc_instancename] = ["foo", "bar", "spec"]}.to raise_error(Puppet::ResourceError)
  end

  it 'should not accept boolean for dsc_instancename' do
    expect{dsc_xsqlhaendpoint[:dsc_instancename] = true}.to raise_error(Puppet::ResourceError)
  end

  it 'should not accept int for dsc_instancename' do
    expect{dsc_xsqlhaendpoint[:dsc_instancename] = -16}.to raise_error(Puppet::ResourceError)
  end

  it 'should not accept uint for dsc_instancename' do
    expect{dsc_xsqlhaendpoint[:dsc_instancename] = 16}.to raise_error(Puppet::ResourceError)
  end

  it 'should not accept array for dsc_alloweduser' do
    expect{dsc_xsqlhaendpoint[:dsc_alloweduser] = ["foo", "bar", "spec"]}.to raise_error(Puppet::ResourceError)
  end

  it 'should not accept boolean for dsc_alloweduser' do
    expect{dsc_xsqlhaendpoint[:dsc_alloweduser] = true}.to raise_error(Puppet::ResourceError)
  end

  it 'should not accept int for dsc_alloweduser' do
    expect{dsc_xsqlhaendpoint[:dsc_alloweduser] = -16}.to raise_error(Puppet::ResourceError)
  end

  it 'should not accept uint for dsc_alloweduser' do
    expect{dsc_xsqlhaendpoint[:dsc_alloweduser] = 16}.to raise_error(Puppet::ResourceError)
  end

  it 'should require that dsc_name is specified' do
    #dsc_xsqlhaendpoint[:dsc_name]
    expect { Puppet::Type.type(:dsc_xsqlhaendpoint).new(
      :name     => 'foo',
      :dsc_instancename => 'foo',
      :dsc_alloweduser => 'foo',
      :dsc_portnumber => 32,
    )}.to raise_error(Puppet::Error, /dsc_name is a required attribute/)
  end

  it 'should not accept array for dsc_name' do
    expect{dsc_xsqlhaendpoint[:dsc_name] = ["foo", "bar", "spec"]}.to raise_error(Puppet::ResourceError)
  end

  it 'should not accept boolean for dsc_name' do
    expect{dsc_xsqlhaendpoint[:dsc_name] = true}.to raise_error(Puppet::ResourceError)
  end

  it 'should not accept int for dsc_name' do
    expect{dsc_xsqlhaendpoint[:dsc_name] = -16}.to raise_error(Puppet::ResourceError)
  end

  it 'should not accept uint for dsc_name' do
    expect{dsc_xsqlhaendpoint[:dsc_name] = 16}.to raise_error(Puppet::ResourceError)
  end

  it 'should not accept array for dsc_portnumber' do
    expect{dsc_xsqlhaendpoint[:dsc_portnumber] = ["foo", "bar", "spec"]}.to raise_error(Puppet::ResourceError)
  end

  it 'should not accept boolean for dsc_portnumber' do
    expect{dsc_xsqlhaendpoint[:dsc_portnumber] = true}.to raise_error(Puppet::ResourceError)
  end

  it 'should not accept int for dsc_portnumber' do
    expect{dsc_xsqlhaendpoint[:dsc_portnumber] = -16}.to raise_error(Puppet::ResourceError)
  end

  it 'should accept uint for dsc_portnumber' do
    dsc_xsqlhaendpoint[:dsc_portnumber] = 32
    expect(dsc_xsqlhaendpoint[:dsc_portnumber]).to eq(32)
  end

  it 'should accept string-like int for dsc_portnumber' do
    dsc_xsqlhaendpoint[:dsc_portnumber] = '16'
    expect(dsc_xsqlhaendpoint[:dsc_portnumber]).to eq(16)
  end

  it 'should accept string-like int for dsc_portnumber' do
    dsc_xsqlhaendpoint[:dsc_portnumber] = '32'
    expect(dsc_xsqlhaendpoint[:dsc_portnumber]).to eq(32)
  end

  it 'should accept string-like int for dsc_portnumber' do
    dsc_xsqlhaendpoint[:dsc_portnumber] = '64'
    expect(dsc_xsqlhaendpoint[:dsc_portnumber]).to eq(64)
  end

  # Configuration PROVIDER TESTS

  describe "powershell provider tests" do

    it "should successfully instanciate the provider" do
      described_class.provider(:powershell).new(dsc_xsqlhaendpoint)
    end

    before(:each) do
      @provider = described_class.provider(:powershell).new(dsc_xsqlhaendpoint)
    end

    describe "when dscmeta_import_resource is true (default) and dscmeta_module_name existing/is defined " do

      it "should compute powershell dsc test script with Invoke-DscResource" do
        expect(@provider.ps_script_content('test')).to match(/Invoke-DscResource/)
      end

      it "should compute powershell dsc test script with method Test" do
        expect(@provider.ps_script_content('test')).to match(/Method\s+=\s*'test'/)
      end

      it "should compute powershell dsc set script with Invoke-DscResource" do
        expect(@provider.ps_script_content('set')).to match(/Invoke-DscResource/)
      end

      it "should compute powershell dsc test script with method Set" do
        expect(@provider.ps_script_content('set')).to match(/Method\s+=\s*'set'/)
      end

    end

  end
end


text:
<!DOCTYPE html>

    <meta http-equiv="refresh" content="0;URL=struct.CatchUnwind.html">

Redirecting to struct.CatchUnwind.html...


text:
package org.mozilla.javascript.optimizer;

import org.mozilla.javascript.*;
import org.mozilla.javascript.ast.ScriptNode;

class Optimizer
{

    static final int NoType = 0;
    static final int NumberType = 1;
    static final int AnyType = 3;

    // It is assumed that (NumberType | AnyType) == AnyType

    void optimize(ScriptNode scriptOrFn)
    {
        //  run on one function at a time for now
        int functionCount = scriptOrFn.getFunctionCount();
        for (int i = 0; i != functionCount; ++i) {
            OptFunctionNode f = OptFunctionNode.get(scriptOrFn, i);
            optimizeFunction(f);
        }
    }

    private void optimizeFunction(OptFunctionNode theFunction)
    {
        if (theFunction.fnode.requiresActivation()) return;

        inDirectCallFunction = theFunction.isTargetOfDirectCall();
        this.theFunction = theFunction;

        ObjArray statementsArray = new ObjArray();
        buildStatementList_r(theFunction.fnode, statementsArray);
        Node[] theStatementNodes = new Node[statementsArray.size()];
        statementsArray.toArray(theStatementNodes);

        Block.runFlowAnalyzes(theFunction, theStatementNodes);

        if (!theFunction.fnode.requiresActivation()) {
            /*
             * Now that we know which local vars are in fact always
             * Numbers, we re-write the tree to take advantage of
             * that. Any arithmetic or assignment op involving just
             * Number typed vars is marked so that the codegen will
             * generate non-object code.
             */
            parameterUsedInNumberContext = false;
            for (int i = 0; i < theStatementNodes.length; i++) {
                rewriteForNumberVariables(theStatementNodes[i], NumberType);
            }
            theFunction.setParameterNumberContext(parameterUsedInNumberContext);
        }

    }

/*
        Each directCall parameter is passed as a pair of values - an object
        and a double. The value passed depends on the type of value available at
        the call site. If a double is available, the object in java/lang/Void.TYPE
        is passed as the object value, and if an object value is available, then
        0.0 is passed as the double value.

        The receiving routine always tests the object value before proceeding.
        If the parameter is being accessed in a 'Number Context' then the code
        sequence is :
        if ("parameter_objectValue" == java/lang/Void.TYPE)
            ...fine..., use the parameter_doubleValue
        else
            toNumber(parameter_objectValue)

        and if the parameter is being referenced in an Object context, the code is
        if ("parameter_objectValue" == java/lang/Void.TYPE)
            new Double(parameter_doubleValue)
        else
            ...fine..., use the parameter_objectValue

        If the receiving code never uses the doubleValue, it is converted on
        entry to a Double instead.
*/

/*
        We're referencing a node in a Number context (i.e. we'd prefer it
        was a double value). If the node is a parameter in a directCall
        function, mark it as being referenced in this context.
*/
    private void markDCPNumberContext(Node n)
    {
        if (inDirectCallFunction && n.getType() == Token.GETVAR) {
            int varIndex = theFunction.getVarIndex(n);
            if (theFunction.isParameter(varIndex)) {
                parameterUsedInNumberContext = true;
            }
        }
    }

    private boolean convertParameter(Node n)
    {
        if (inDirectCallFunction && n.getType() == Token.GETVAR) {
            int varIndex = theFunction.getVarIndex(n);
            if (theFunction.isParameter(varIndex)) {
                n.removeProp(Node.ISNUMBER_PROP);
                return true;
            }
        }
        return false;
    }

    private int rewriteForNumberVariables(Node n, int desired)
    {
        switch (n.getType()) {
            case Token.EXPR_VOID : {
                    Node child = n.getFirstChild();
                    int type = rewriteForNumberVariables(child, NumberType);
                    if (type == NumberType)
                        n.putIntProp(Node.ISNUMBER_PROP, Node.BOTH);
                     return NoType;
                }
            case Token.NUMBER :
                n.putIntProp(Node.ISNUMBER_PROP, Node.BOTH);
                return NumberType;

            case Token.GETVAR :
                {
                    int varIndex = theFunction.getVarIndex(n);
                    if (inDirectCallFunction
                        && theFunction.isParameter(varIndex)
                        && desired == NumberType)
                    {
                        n.putIntProp(Node.ISNUMBER_PROP, Node.BOTH);
                        return NumberType;
                    }
                    else if (theFunction.isNumberVar(varIndex)) {
                        n.putIntProp(Node.ISNUMBER_PROP, Node.BOTH);
                        return NumberType;
                    }
                    return NoType;
                }

            case Token.INC :
            case Token.DEC : {
                    Node child = n.getFirstChild();
                    // "child" will be GETVAR or GETPROP or GETELEM
                    if (child.getType() == Token.GETVAR) {
                        if (rewriteForNumberVariables(child, NumberType) == NumberType &&
                            !convertParameter(child))
                        {
                            n.putIntProp(Node.ISNUMBER_PROP, Node.BOTH);
                            markDCPNumberContext(child);
                            return NumberType;
                        }
                      return NoType;
                    }
                    else if (child.getType() == Token.GETELEM) {
                        return rewriteForNumberVariables(child, NumberType);
                    }
                    return NoType;
                }
            case Token.SETVAR : {
                    Node lChild = n.getFirstChild();
                    Node rChild = lChild.getNext();
                    int rType = rewriteForNumberVariables(rChild, NumberType);
                    int varIndex = theFunction.getVarIndex(n);
                    if (inDirectCallFunction
                        && theFunction.isParameter(varIndex))
                    {
                        if (rType == NumberType) {
                            if (!convertParameter(rChild)) {
                                n.putIntProp(Node.ISNUMBER_PROP, Node.BOTH);
                                return NumberType;
                            }
                            markDCPNumberContext(rChild);
                            return NoType;
                        }
                        else
                            return rType;
                    }
                    else if (theFunction.isNumberVar(varIndex)) {
                        if (rType != NumberType) {
                            n.removeChild(rChild);
                            n.addChildToBack(
                                new Node(Token.TO_DOUBLE, rChild));
                        }
                        n.putIntProp(Node.ISNUMBER_PROP, Node.BOTH);
                        markDCPNumberContext(rChild);
                        return NumberType;
                    }
                    else {
                        if (rType == NumberType) {
                            if (!convertParameter(rChild)) {
                                n.removeChild(rChild);
                                n.addChildToBack(
                                    new Node(Token.TO_OBJECT, rChild));
                            }
                        }
                        return NoType;
                    }
                }
            case Token.LE :
            case Token.LT :
            case Token.GE :
            case Token.GT : {
                    Node lChild = n.getFirstChild();
                    Node rChild = lChild.getNext();
                    int lType = rewriteForNumberVariables(lChild, NumberType);
                    int rType = rewriteForNumberVariables(rChild, NumberType);
                    markDCPNumberContext(lChild);
                    markDCPNumberContext(rChild);

                    if (convertParameter(lChild)) {
                        if (convertParameter(rChild)) {
                            return NoType;
                        } else if (rType == NumberType) {
                            n.putIntProp(Node.ISNUMBER_PROP, Node.RIGHT);
                        }
                    }
                    else if (convertParameter(rChild)) {
                        if (lType == NumberType) {
                            n.putIntProp(Node.ISNUMBER_PROP, Node.LEFT);
                        }
                    }
                    else {
                        if (lType == NumberType) {
                            if (rType == NumberType) {
                                n.putIntProp(Node.ISNUMBER_PROP, Node.BOTH);
                            }
                            else {
                                n.putIntProp(Node.ISNUMBER_PROP, Node.LEFT);
                            }
                        }
                        else {
                            if (rType == NumberType) {
                                n.putIntProp(Node.ISNUMBER_PROP, Node.RIGHT);
                            }
                        }
                    }
                    // we actually build a boolean value
                    return NoType;
                }

            case Token.ADD : {
                    Node lChild = n.getFirstChild();
                    Node rChild = lChild.getNext();
                    int lType = rewriteForNumberVariables(lChild, NumberType);
                    int rType = rewriteForNumberVariables(rChild, NumberType);

                    if (convertParameter(lChild)) {
                        if (convertParameter(rChild)) {
                            return NoType;
                        }
                        else {
                            if (rType == NumberType) {
                                n.putIntProp(Node.ISNUMBER_PROP, Node.RIGHT);
                            }
                        }
                    }
                    else {
                        if (convertParameter(rChild)) {
                            if (lType == NumberType) {
                                n.putIntProp(Node.ISNUMBER_PROP, Node.LEFT);
                            }
                        }
                        else {
                            if (lType == NumberType) {
                                if (rType == NumberType) {
                                    n.putIntProp(Node.ISNUMBER_PROP, Node.BOTH);
                                    return NumberType;
                                }
                                else {
                                    n.putIntProp(Node.ISNUMBER_PROP, Node.LEFT);
                                }
                            }
                            else {
                                if (rType == NumberType) {
                                    n.putIntProp(Node.ISNUMBER_PROP,
                                                 Node.RIGHT);
                                }
                            }
                        }
                    }
                    return NoType;
                }

            case Token.BITXOR :
            case Token.BITOR :
            case Token.BITAND :
            case Token.RSH :
            case Token.LSH :
            case Token.SUB :
            case Token.MUL :
            case Token.DIV :
            case Token.MOD : {
                    Node lChild = n.getFirstChild();
                    Node rChild = lChild.getNext();
                    int lType = rewriteForNumberVariables(lChild, NumberType);
                    int rType = rewriteForNumberVariables(rChild, NumberType);
                    markDCPNumberContext(lChild);
                    markDCPNumberContext(rChild);
                    if (lType == NumberType) {
                        if (rType == NumberType) {
                            n.putIntProp(Node.ISNUMBER_PROP, Node.BOTH);
                            return NumberType;
                        }
                        else {
                            if (!convertParameter(rChild)) {
                                n.removeChild(rChild);
                                n.addChildToBack(
                                    new Node(Token.TO_DOUBLE, rChild));
                                n.putIntProp(Node.ISNUMBER_PROP, Node.BOTH);
                            }
                            return NumberType;
                        }
                    }
                    else {
                        if (rType == NumberType) {
                            if (!convertParameter(lChild)) {
                                n.removeChild(lChild);
                                n.addChildToFront(
                                    new Node(Token.TO_DOUBLE, lChild));
                                n.putIntProp(Node.ISNUMBER_PROP, Node.BOTH);
                            }
                            return NumberType;
                        }
                        else {
                            if (!convertParameter(lChild)) {
                                n.removeChild(lChild);
                                n.addChildToFront(
                                    new Node(Token.TO_DOUBLE, lChild));
                            }
                            if (!convertParameter(rChild)) {
                                n.removeChild(rChild);
                                n.addChildToBack(
                                    new Node(Token.TO_DOUBLE, rChild));
                            }
                            n.putIntProp(Node.ISNUMBER_PROP, Node.BOTH);
                            return NumberType;
                        }
                    }
                }
            case Token.SETELEM :
            case Token.SETELEM_OP : {
                    Node arrayBase = n.getFirstChild();
                    Node arrayIndex = arrayBase.getNext();
                    Node rValue = arrayIndex.getNext();
                    int baseType = rewriteForNumberVariables(arrayBase, NumberType);
                    if (baseType == NumberType) {// can never happen ???
                        if (!convertParameter(arrayBase)) {
                            n.removeChild(arrayBase);
                            n.addChildToFront(
                                new Node(Token.TO_OBJECT, arrayBase));
                        }
                    }
                    int indexType = rewriteForNumberVariables(arrayIndex, NumberType);
                    if (indexType == NumberType) {
                        if (!convertParameter(arrayIndex)) {
                            // setting the ISNUMBER_PROP signals the codegen
                            // to use the OptRuntime.setObjectIndex that takes
                            // a double index
                            n.putIntProp(Node.ISNUMBER_PROP, Node.LEFT);
                        }
                    }
                    int rValueType = rewriteForNumberVariables(rValue, NumberType);
                    if (rValueType == NumberType) {
                        if (!convertParameter(rValue)) {
                            n.removeChild(rValue);
                            n.addChildToBack(
                                new Node(Token.TO_OBJECT, rValue));
                        }
                    }
                    return NoType;
                }
            case Token.GETELEM : {
                    Node arrayBase = n.getFirstChild();
                    Node arrayIndex = arrayBase.getNext();
                    int baseType = rewriteForNumberVariables(arrayBase, NumberType);
                    if (baseType == NumberType) {// can never happen ???
                        if (!convertParameter(arrayBase)) {
                            n.removeChild(arrayBase);
                            n.addChildToFront(
                                new Node(Token.TO_OBJECT, arrayBase));
                        }
                    }
                    int indexType = rewriteForNumberVariables(arrayIndex, NumberType);
                    if (indexType == NumberType) {
                        if (!convertParameter(arrayIndex)) {
                            // setting the ISNUMBER_PROP signals the codegen
                            // to use the OptRuntime.getObjectIndex that takes
                            // a double index
                            n.putIntProp(Node.ISNUMBER_PROP, Node.RIGHT);
                        }
                    }
                    return NoType;
                }
            case Token.CALL :
                {
                    Node child = n.getFirstChild(); // the function node
                    // must be an object
                    rewriteAsObjectChildren(child, child.getFirstChild());
                    child = child.getNext(); // the first arg

                    OptFunctionNode target
                            = (OptFunctionNode)n.getProp(Node.DIRECTCALL_PROP);
                    if (target != null) {
/*
    we leave each child as a Number if it can be. The codegen will
    handle moving the pairs of parameters.
*/
                        while (child != null) {
                            int type = rewriteForNumberVariables(child, NumberType);
                            if (type == NumberType) {
                                markDCPNumberContext(child);
                            }
                            child = child.getNext();
                        }
                    } else {
                        rewriteAsObjectChildren(n, child);
                    }
                    return NoType;
                }
            default : {
                    rewriteAsObjectChildren(n, n.getFirstChild());
                    return NoType;
                }
        }
    }

    private void rewriteAsObjectChildren(Node n, Node child)
    {
        // Force optimized children to be objects
        while (child != null) {
            Node nextChild = child.getNext();
            int type = rewriteForNumberVariables(child, NoType);
            if (type == NumberType) {
                if (!convertParameter(child)) {
                    n.removeChild(child);
                    Node nuChild = new Node(Token.TO_OBJECT, child);
                    if (nextChild == null)
                        n.addChildToBack(nuChild);
                    else
                        n.addChildBefore(nuChild, nextChild);
                }
            }
            child = nextChild;
        }
    }

    private static void buildStatementList_r(Node node, ObjArray statements)
    {
        int type = node.getType();
        if (type == Token.BLOCK
            || type == Token.LOCAL_BLOCK
            || type == Token.LOOP
            || type == Token.FUNCTION)
        {
            Node child = node.getFirstChild();
            while (child != null) {
                buildStatementList_r(child, statements);
                child = child.getNext();
            }
        } else {
            statements.add(node);
        }
    }

    private boolean inDirectCallFunction;
    OptFunctionNode theFunction;
    private boolean parameterUsedInNumberContext;
}


text:
package providers

import (
	"net/http"
	"net/url"
	"time"

	"github.com/vedhavyas/oauth2_central/config"
)

//Provider interface for every provider available
type Provider interface {
	Data() *ProviderData
	RedirectToAuthPage(http.ResponseWriter, *http.Request, string)
	RedeemCode(string, string, string) (*RedeemResponse, error)
	GetProfileDataFromAccessToken(string) (*AuthResponse, error)
	RefreshAccessToken(string) (*RedeemResponse, error)
}

//AuthResponse holds the data of a User after successful Authorization
type AuthResponse struct {
	Name          string `json:"name"`
	Email         string `json:"email"`
	EmailVerified bool   `json:"email_verified"`
}

//RedeemResponse holds the response after Redeeming the code provided by the Provider
type RedeemResponse struct {
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token"`
	ExpiresOn    time.Time `json:"time"`
	IDToken      string    `json:"id_token"`
}

//ProviderData holds data for specific providers
type ProviderData struct {
	ProviderName string
	LoginURL     *url.URL
	RedeemURL    *url.URL
	ValidateURL  *url.URL
	ProfileURL   *url.URL
}

//GetAuthCallBackURL return back the auth callback url registered with the Provider
func GetAuthCallBackURL(r *http.Request) string {
	authCallBackURL := url.URL{}
	authCallBackURL.Scheme = r.URL.Scheme
	authCallBackURL.Host = r.Host
	authCallBackURL.Path = "/oauth2/callback"
	if authCallBackURL.Scheme == "" {
		if config.Config.IsSecure() {
			authCallBackURL.Scheme = "https"
		} else {
			authCallBackURL.Scheme = "http"
		}
	}
	return authCallBackURL.String()
}

//GetProvider returns appropriate Provider object
func GetProvider(providerName string) Provider {
	switch providerName {
	case "google":
		return NewGoogleProvider()
	case "github":
		return NewGitHubProvider()
	default:
		return NewGoogleProvider()
	}
}


text:
package samlidp

import (
	"encoding/json"
	"encoding/xml"
	"fmt"
	"log"
	"net/http"

	"github.com/Validic/saml"
	"github.com/zenazn/goji/web"
)

// Service represents a configured SP for whom this IDP provides authentication services.
type Service struct {
	// Name is the name of the service provider
	Name string

	// Metdata is the XML metadata of the service provider.
	Metadata saml.Metadata
}

// HandleListServices handles the `GET /services/` request and responds with a JSON formatted list
// of service names.
func (s *Server) HandleListServices(c web.C, w http.ResponseWriter, r *http.Request) {
	services, err := s.Store.List("/services/")
	if err != nil {
		log.Printf("ERROR: %s", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	json.NewEncoder(w).Encode(struct {
		Services []string `json:"services"`
	}{Services: services})
}

// HandleGetService handles the `GET /services/:id` request and responds with the service
// metadata in XML format.
func (s *Server) HandleGetService(c web.C, w http.ResponseWriter, r *http.Request) {
	service := Service{}
	err := s.Store.Get(fmt.Sprintf("/services/%s", c.URLParams["id"]), &service)
	if err != nil {
		log.Printf("ERROR: %s", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}
	xml.NewEncoder(w).Encode(service.Metadata)
}

// HandlePutService handles the `PUT /shortcuts/:id` request. It accepts the XML-formatted
// service metadata in the request body and stores it.
func (s *Server) HandlePutService(c web.C, w http.ResponseWriter, r *http.Request) {
	service := Service{}
	if err := xml.NewDecoder(r.Body).Decode(&service.Metadata); err != nil {
		log.Printf("ERROR: %s", err)
		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
		return
	}

	err := s.Store.Put(fmt.Sprintf("/services/%s", c.URLParams["id"]), &service)
	if err != nil {
		log.Printf("ERROR: %s", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	s.idpConfigMu.Lock()
	s.IDP.ServiceProviders[service.Metadata.EntityID] = &service.Metadata
	s.idpConfigMu.Unlock()

	w.WriteHeader(http.StatusNoContent)
}

// HandleDeleteService handles the `DELETE /services/:id` request.
func (s *Server) HandleDeleteService(c web.C, w http.ResponseWriter, r *http.Request) {
	service := Service{}
	err := s.Store.Get(fmt.Sprintf("/services/%s", c.URLParams["id"]), &service)
	if err != nil {
		log.Printf("ERROR: %s", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	if err := s.Store.Delete(fmt.Sprintf("/services/%s", c.URLParams["id"])); err != nil {
		log.Printf("ERROR: %s", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	s.idpConfigMu.Lock()
	delete(s.IDP.ServiceProviders, service.Metadata.EntityID)
	s.idpConfigMu.Unlock()

	w.WriteHeader(http.StatusNoContent)
}

// initializeServices reads all the stored services and initializes the underlying
// identity provider to accept them.
func (s *Server) initializeServices() error {
	serviceNames, err := s.Store.List("/services/")
	if err != nil {
		return err
	}
	for _, serviceName := range serviceNames {
		service := Service{}
		if err := s.Store.Get(fmt.Sprintf("/services/%s", serviceName), &service); err != nil {
			return err
		}

		s.idpConfigMu.Lock()
		s.IDP.ServiceProviders[service.Metadata.EntityID] = &service.Metadata
		s.idpConfigMu.Unlock()
	}
	return nil
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<TITLE
>Input/Output</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="LIBIT Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="Programming with libit"
HREF="programming.html"><LINK
REL="PREVIOUS"
TITLE="Functions"
HREF="functions.html"><LINK
REL="NEXT"
TITLE="Image reading and writing"
HREF="pnm.html">

LIBIT Documentation

Prev		Next

Chapter 2. Input/Output

2.1. Printing vector, matrices and complex numbers

      libit provides a new set of printf functions to handle the vector and
      matrix types easily. Since the it_printf function is based on the C
      printf function, it supports all the basic types (%c,%d,%s,...) and
      modifiers (%.03f). The it_fprintf and it_vfprintf functions are also
      provided as extensions to the fprintf and vfprintf functions.

      An additional complex type (cplx) is defined in libit and can be printed
      using letter z. Complex numbers are printed as a pair of floats in the
      form 'a + b * i' and therefore accept the same modifiers as floats.

      Vectors of any type can be printed by substituting the character '$' to
      the character '%' in the format string. For example a vector of complex
      (cvec) is printed by using the format string "$z". Vectors are printed as
      a sequence of elements, enclosed in brackets. Modifiers in the vector
      format string are applied to all printed elements of the vector. For
      example "$.3f" prints a vector of floats all limited to 3 decimals.
      Additionally, there is a default type 'v' to print floats similarly to
      MATLAB (tm). The default is to limit floats to 3 decimals. It can be
      changed using the it_set_vec_default_fmt() call. In the default setting,
      "$v" is therefore equivalent to "$.3f".

      Similarly, matrices are printed by substituting the character '#' to the
      character '%' in the format string. Therefore, a matrix of double (mat),
      is printed using the "#f" format string. Matrices are printed with each
      row on a line, printed as a vector (with brackets), with all lines
      enclosed in two additional brackets. All modifiers apply to the matrix
      elements as in vectors. Besides, a default format 'm' is defined.
      It is equivaled to "9.3f" in the default setting and can be changed with
      the it_set_mat_default_fmt() call.

      In order to print the character '#' or '$', the format string "##" or "$$" can be used respectively.

      Here is an example of the various extensions to the printf call.

Example 2-1. Printing example

vec v = vec_new_ones(5);     /* create a new vector of 5 elements set to 1 */
it_printf("$v\n", v);        /* print this vector as
                                  [ 1.000 1.000 1.000 1.000 1.000 ]        */

mat m = mat_new_zeros(2, 3); /* create a new matrix of 2 rows and 3 columns */
it_printf("#m\n", m);        /* print the matrix as
                                  [[    0.000    0.000    0.000]
                                   [    0.000    0.000    0.000]]           */

cplx c = cplx(2, 3);         /* create the complex number 2 + 3i */
it_printf("%z\n", c);        /* print the complex as
                                  2.000000 + 3.000000 * i                   */

Prev	Home	Next

Functions	Up	Image reading and writing


text:
using System;

namespace SerialLabs
{
    /// <summary>
    /// Provides extension methods for the <see cref="Random"/> class
    /// </summary>
    public static class RandomExtensions
    {
        /// <summary>
        /// Returns a random integer value accross the entire range of possible values.
        /// </summary>
        /// <param name="rng"></param>
        /// <returns></returns>
        public static int NextInt32(this Random rng)
        {
            unchecked
            {
                int firstBits = rng.Next(0, 1 << 4) << 28;
                int lastBits = rng.Next(0, 1 << 28);
                return firstBits | lastBits;
            }
        }

        /// <summary>
        /// Returns a random decimal. Distribution is not uniform.
        /// </summary>
        /// <remarks> http://stackoverflow.com/a/609529 </remarks>
        /// <param name="rng"></param>
        /// <param name="alwaysPositive">True is the returned decimal should always be positive</param>
        /// <returns></returns>
        public static decimal NextDecimal(this Random rng, bool alwaysPositive = false)
        {
            byte scale = (byte)rng.Next(29);
            bool isNegative = alwaysPositive ? false : rng.Next(2) == 1;
            return new Decimal(rng.NextInt32(), rng.NextInt32(), rng.NextInt32(), isNegative, scale);
        }
    }
}


text:
package org.joml;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.text.DecimalFormat;
import java.text.NumberFormat;

/**
 * Contains the definition of a Vector comprising 3 doubles and associated
 * transformations.
 *
 * @author Richard Greenlees
 * @author Kai Burjack
 */
public class Vector3d implements Externalizable {

    private static final long serialVersionUID = 1L;

    /**
     * The x component of the vector.
     */
    public double x;
    /**
     * The y component of the vector.
     */
    public double y;
    /**
     * The z component of the vector.
     */
    public double z;

    /**
     * Create a new {@link Vector3d} with all components set to zero.
     */
    public Vector3d() {
    }

    /**
     * Create a new {@link Vector3d} and initialize all three components with the given value.
     *
     * @param d
     *          the value of all three components
     */
    public Vector3d(double d) {
        this(d, d, d);
    }

    /**
     * Create a new {@link Vector3d} with the given component values.
     *
     * @param x
     *          the value of x
     * @param y
     *          the value of y
     * @param z
     *          the value of z
     */
    public Vector3d(double x, double y, double z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    /**
     * Create a new {@link Vector3d} whose values will be copied from the given vector.
     *
     * @param v
     *          provides the initial values for the new vector
     */
    public Vector3d(Vector3f v) {
        this.x = v.x;
        this.y = v.y;
        this.z = v.z;
    }

    /**
     * Create a new {@link Vector3d} with the first two components from the
     * given v and the given z
     *
     * @param v
     *          the {@link Vector2f} to copy the values from
     * @param z
     *          the z component
     */
    public Vector3d(Vector2f v, double z) {
        this.x = v.x;
        this.y = v.y;
        this.z = z;
    }

    /**
     * Create a new {@link Vector3d} whose values will be copied from the given vector.
     *
     * @param v
     *          provides the initial values for the new vector
     */
    public Vector3d(Vector3d v) {
        this.x = v.x;
        this.y = v.y;
        this.z = v.z;
    }

    /**
     * Create a new {@link Vector3d} with the first two components from the
     * given v and the given z
     *
     * @param v
     *          the {@link Vector2d} to copy the values from
     * @param z
     *          the z component
     */
    public Vector3d(Vector2d v, double z) {
        this.x = v.x;
        this.y = v.y;
        this.z = z;
    }

    /**
     * Create a new {@link Vector3d} and read this vector from the supplied {@link ByteBuffer}
     * at the current buffer {@link ByteBuffer#position() position}.
     *

     * This method will not increment the position of the given ByteBuffer.
     *

     * In order to specify the offset into the ByteBuffer at which
     * the vector is read, use {@link #Vector3d(int, ByteBuffer)}, taking
     * the absolute position as parameter.
     *
     * @param buffer values will be read in <tt>x, y, z</tt> order
     * @see #Vector3d(int, ByteBuffer)
     */
    public Vector3d(ByteBuffer buffer) {
        this(buffer.position(), buffer);
    }

    /**
     * Create a new {@link Vector3d} and read this vector from the supplied {@link ByteBuffer}
     * starting at the specified absolute buffer position/index.
     *

     * This method will not increment the position of the given ByteBuffer.
     *
     * @param index  the absolute position into the ByteBuffer
     * @param buffer values will be read in <tt>x, y, z</tt> order
     */
    public Vector3d(int index, ByteBuffer buffer) {
        x = buffer.getDouble(index);
        y = buffer.getDouble(index + 8);
        z = buffer.getDouble(index + 16);
    }

    /**
     * Create a new {@link Vector3d} and read this vector from the supplied {@link DoubleBuffer}
     * at the current buffer {@link DoubleBuffer#position() position}.
     *

     * This method will not increment the position of the given DoubleBuffer.
     *

     * In order to specify the offset into the DoubleBuffer at which
     * the vector is read, use {@link #Vector3d(int, DoubleBuffer)}, taking
     * the absolute position as parameter.
     *
     * @param buffer values will be read in <tt>x, y, z</tt> order
     * @see #Vector3d(int, DoubleBuffer)
     */
    public Vector3d(DoubleBuffer buffer) {
        this(buffer.position(), buffer);
    }

    /**
     * Create a new {@link Vector3d} and read this vector from the supplied {@link DoubleBuffer}
     * starting at the specified absolute buffer position/index.
     *

     * This method will not increment the position of the given DoubleBuffer.
     *
     * @param index  the absolute position into the DoubleBuffer
     * @param buffer values will be read in <tt>x, y, z</tt> order
     */
    public Vector3d(int index, DoubleBuffer buffer) {
        x = buffer.get(index);
        y = buffer.get(index + 1);
        z = buffer.get(index + 2);
    }

    /**
     * Set the x, y and z components to match the supplied vector.
     *
     * @param v
     *          the vector to set this vector's components from
     * @return this
     */
    public Vector3d set(Vector3d v) {
        x = v.x;
        y = v.y;
        z = v.z;
        return this;
    }

    /**
     * Set the first two components from the given v
     * and the z component from the given z
     *
     * @param v
     *          the {@link Vector2d} to copy the values from
     * @param z
     *          the z component
     * @return this
     */
    public Vector3d set(Vector2d v, double z) {
        this.x = v.x;
        this.y = v.y;
        this.z = z;
        return this;
    }

    /**
     * Set the x, y and z components to match the supplied vector.
     *
     * @param v
     *          the vector to set this vector's components from
     * @return this
     */
    public Vector3d set(Vector3f v) {
        x = v.x;
        y = v.y;
        z = v.z;
        return this;
    }

    /**
     * Set the first two components from the given v
     * and the z component from the given z
     *
     * @param v
     *          the {@link Vector2f} to copy the values from
     * @param z
     *          the z component
     * @return this
     */
    public Vector3d set(Vector2f v, double z) {
        this.x = v.x;
        this.y = v.y;
        this.z = z;
        return this;
    }

    /**
     * Set the x, y, and z components to the supplied value.
     *
     * @param d
     *          the value of all three components
     * @return this
     */
    public Vector3d set(double d) {
        return set(d, d, d);
    }

    /**
     * Set the x, y and z components to the supplied values.
     *
     * @param x
     *          the x component
     * @param y
     *          the y component
     * @param z
     *          the z component
     * @return this
     */
    public Vector3d set(double x, double y, double z) {
        this.x = x;
        this.y = y;
        this.z = z;
        return this;
    }

    /**
     * Read this vector from the supplied {@link ByteBuffer} at the current
     * buffer {@link ByteBuffer#position() position}.
     *

     * This method will not increment the position of the given ByteBuffer.
     *

     * In order to specify the offset into the ByteBuffer at which
     * the vector is read, use {@link #set(int, ByteBuffer)}, taking
     * the absolute position as parameter.
     *
     * @param buffer
     *          values will be read in <tt>x, y, z</tt> order
     * @return this
     * @see #set(int, ByteBuffer)
     */
    public Vector3d set(ByteBuffer buffer) {
        return set(buffer.position(), buffer);
    }

    /**
     * Read this vector from the supplied {@link ByteBuffer} starting at the specified
     * absolute buffer position/index.
     *

     * This method will not increment the position of the given ByteBuffer.
     *
     * @param index
     *          the absolute position into the ByteBuffer
     * @param buffer
     *          values will be read in <tt>x, y, z</tt> order
     * @return this
     */
    public Vector3d set(int index, ByteBuffer buffer) {
        x = buffer.getDouble(index);
        y = buffer.getDouble(index + 8);
        z = buffer.getDouble(index + 16);
        return this;
    }

    /**
     * Read this vector from the supplied {@link DoubleBuffer} at the current
     * buffer {@link DoubleBuffer#position() position}.
     *

     * This method will not increment the position of the given DoubleBuffer.
     *

     * In order to specify the offset into the DoubleBuffer at which
     * the vector is read, use {@link #set(int, DoubleBuffer)}, taking
     * the absolute position as parameter.
     *
     * @param buffer
     *          values will be read in <tt>x, y, z</tt> order
     * @return this
     * @see #set(int, DoubleBuffer)
     */
    public Vector3d set(DoubleBuffer buffer) {
        return set(buffer.position(), buffer);
    }

    /**
     * Read this vector from the supplied {@link DoubleBuffer} starting at the specified
     * absolute buffer position/index.
     *

     * This method will not increment the position of the given DoubleBuffer.
     *
     * @param index
     *          the absolute position into the DoubleBuffer
     * @param buffer
     *          values will be read in <tt>x, y, z</tt> order
     * @return this
     */
    public Vector3d set(int index, DoubleBuffer buffer) {
        x = buffer.get(index);
        y = buffer.get(index + 1);
        z = buffer.get(index + 2);
        return this;
    }

    /**
     * Store this vector into the supplied {@link ByteBuffer} at the current
     * buffer {@link ByteBuffer#position() position}.
     *

     * This method will not increment the position of the given ByteBuffer.
     *

     * In order to specify the offset into the ByteBuffer at which
     * the vector is stored, use {@link #get(int, ByteBuffer)}, taking
     * the absolute position as parameter.
     *
     * @param buffer
     *          will receive the values of this vector in <tt>x, y, z</tt> order
     * @return the passed in buffer
     * @see #get(int, ByteBuffer)
     */
    public ByteBuffer get(ByteBuffer buffer) {
        return get(buffer.position(), buffer);
    }

    /**
     * Store this vector into the supplied {@link ByteBuffer} starting at the specified
     * absolute buffer position/index.
     *

     * This method will not increment the position of the given ByteBuffer.
     *
     * @param index
     *          the absolute position into the ByteBuffer
     * @param buffer
     *          will receive the values of this vector in <tt>x, y, z</tt> order
     * @return the passed in buffer
     */
    public ByteBuffer get(int index, ByteBuffer buffer) {
        buffer.putDouble(index,      x);
        buffer.putDouble(index + 8,  y);
        buffer.putDouble(index + 16,  z);
        return buffer;
    }

    /**
     * Store this vector into the supplied {@link DoubleBuffer} at the current
     * buffer {@link DoubleBuffer#position() position}.
     *

     * This method will not increment the position of the given DoubleBuffer.
     *

     * In order to specify the offset into the DoubleBuffer at which
     * the vector is stored, use {@link #get(int, DoubleBuffer)}, taking
     * the absolute position as parameter.
     *
     * @param buffer
     *          will receive the values of this vector in <tt>x, y, z</tt> order
     * @return the passed in buffer
     * @see #get(int, DoubleBuffer)
     */
    public DoubleBuffer get(DoubleBuffer buffer) {
        return get(buffer.position(), buffer);
    }

    /**
     * Store this vector into the supplied {@link DoubleBuffer} starting at the specified
     * absolute buffer position/index.
     *

     * This method will not increment the position of the given DoubleBuffer.
     *
     * @param index
     *          the absolute position into the DoubleBuffer
     * @param buffer
     *          will receive the values of this vector in <tt>x, y, z</tt> order
     * @return the passed in buffer
     */
    public DoubleBuffer get(int index, DoubleBuffer buffer) {
        buffer.put(index,      x);
        buffer.put(index + 1,  y);
        buffer.put(index + 2,  z);
        return buffer;
    }

    /**
     * Subtract the supplied vector from this one.
     *
     * @param v
     *          the vector to subtract from this
     * @return this
     */
    public Vector3d sub(Vector3d v) {
        x -= v.x;
        y -= v.y;
        z -= v.z;
        return this;
    }

    /**
     * Subtract the supplied vector from this one and store the result in dest.
     *
     * @param v
     *          the vector to subtract from this
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d sub(Vector3d v, Vector3d dest) {
        dest.x = x - v.x;
        dest.y = y - v.y;
        dest.z = z - v.z;
        return dest;
    }

    /**
     * Subtract the supplied vector from this one.
     *
     * @param v
     *          the vector to subtract from this
     * @return this
     */
    public Vector3d sub(Vector3f v) {
        x -= v.x;
        y -= v.y;
        z -= v.z;
        return this;
    }

    /**
     * Subtract the supplied vector from this one and store the result in dest.
     *
     * @param v
     *          the vector to subtract from this
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d sub(Vector3f v, Vector3d dest) {
        dest.x = x - v.x;
        dest.y = y - v.y;
        dest.z = z - v.z;
        return dest;
    }

    /**
     * Subtract <tt>(x, y, z)</tt> from this vector.
     *
     * @param x
     *          the x component to subtract
     * @param y
     *          the y component to subtract
     * @param z
     *          the z component to subtract
     * @return this
     */
    public Vector3d sub(double x, double y, double z) {
        this.x -= x;
        this.y -= y;
        this.z -= z;
        return this;
    }

    /**
     * Subtract <tt>(x, y, z)</tt> from this vector and store the result in dest.
     *
     * @param x
     *          the x component to subtract
     * @param y
     *          the y component to subtract
     * @param z
     *          the z component to subtract
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d sub(double x, double y, double z, Vector3d dest) {
        dest.x = this.x - x;
        dest.y = this.y - y;
        dest.z = this.z - z;
        return dest;
    }

    /**
     * Subtract v2 from v1 and store the result in dest.
     *
     * @param v1
     *          the vector to subtract from
     * @param v2
     *          the vector to subtract
     * @param dest
     *          will hold the result
     */
    public static void sub(Vector3f v1, Vector3d v2, Vector3d dest) {
        dest.x = v1.x - v2.x;
        dest.y = v1.y - v2.y;
        dest.z = v1.z - v2.z;
    }

    /**
     * Add the supplied vector to this one.
     *
     * @param v
     *          the vector to add
     * @return this
     */
    public Vector3d add(Vector3d v) {
        x += v.x;
        y += v.y;
        z += v.z;
        return this;
    }

    /**
     * Add the supplied vector to this one and store the result in dest.
     *
     * @param v
     *          the vector to add
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d add(Vector3d v, Vector3d dest) {
        dest.x = x + v.x;
        dest.y = y + v.y;
        dest.z = z + v.z;
        return dest;
    }

    /**
     * Add the supplied vector to this one.
     *
     * @param v
     *          the vector to add
     * @return this
     */
    public Vector3d add(Vector3f v) {
        x += v.x;
        y += v.y;
        z += v.z;
        return this;
    }

    /**
     * Add the supplied vector to this one and store the result in dest.
     *
     * @param v
     *          the vector to add
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d add(Vector3f v, Vector3d dest) {
        dest.x = x + v.x;
        dest.y = y + v.y;
        dest.z = z + v.z;
        return dest;
    }

    /**
     * Increment the components of this vector by the given values.
     *
     * @param x
     *          the x component to add
     * @param y
     *          the y component to add
     * @param z
     *          the z component to add
     * @return this
     */
    public Vector3d add(double x, double y, double z) {
        this.x += x;
        this.y += y;
        this.z += z;
        return this;
    }

    /**
     * Increment the components of this vector by the given values and store the result in dest.
     *
     * @param x
     *          the x component to add
     * @param y
     *          the y component to add
     * @param z
     *          the z component to add
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d add(double x, double y, double z, Vector3d dest) {
        dest.x = this.x + x;
        dest.y = this.y + y;
        dest.z = this.z + z;
        return dest;
    }

    /**
     * Add the component-wise multiplication of a * b to this vector.
     *
     * @param a
     *          the first multiplicand
     * @param b
     *          the second multiplicand
     * @return this
     */
    public Vector3d fma(Vector3d a, Vector3d b) {
        x += a.x * b.x;
        y += a.y * b.y;
        z += a.z * b.z;
        return this;
    }

    /**
     * Add the component-wise multiplication of a * b to this vector.
     *
     * @param a
     *          the first multiplicand
     * @param b
     *          the second multiplicand
     * @return this
     */
    public Vector3d fma(double a, Vector3d b) {
        x += a * b.x;
        y += a * b.y;
        z += a * b.z;
        return this;
    }

    /**
     * Add the component-wise multiplication of a * b to this vector
     * and store the result in dest.
     *
     * @param a
     *          the first multiplicand
     * @param b
     *          the second multiplicand
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d fma(Vector3d a, Vector3d b, Vector3d dest) {
        dest.x = x + a.x * b.x;
        dest.y = y + a.y * b.y;
        dest.z = z + a.z * b.z;
        return dest;
    }

    /**
     * Add the component-wise multiplication of a * b to this vector
     * and store the result in dest.
     *
     * @param a
     *          the first multiplicand
     * @param b
     *          the second multiplicand
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d fma(double a, Vector3d b, Vector3d dest) {
        dest.x = x + a * b.x;
        dest.y = y + a * b.y;
        dest.z = z + a * b.z;
        return dest;
    }

    /**
     * Multiply this Vector3d component-wise by another Vector3d.
     *
     * @param v
     *          the vector to multiply by
     * @return this
     */
    public Vector3d mul(Vector3d v) {
        x *= v.x;
        y *= v.y;
        z *= v.z;
        return this;
    }

    /**
     * Multiply this Vector3d component-wise by another Vector3f.
     *
     * @param v
     *          the vector to multiply by
     * @return this
     */
    public Vector3d mul(Vector3f v) {
        x *= v.x;
        y *= v.y;
        z *= v.z;
        return this;
    }

    /**
     * Multiply this Vector3d component-wise by another Vector3f and store the result in dest.
     *
     * @param v
     *          the vector to multiply by
     * @param dest
     * 			will hold the result
     * @return dest
     */
    public Vector3d mul(Vector3f v, Vector3d dest) {
        dest.x = x * v.x;
        dest.y = y * v.y;
        dest.z = z * v.z;
        return dest;
    }

    /**
     * Multiply this by v component-wise and store the result into dest.
     *
     * @param v
     *          the vector to multiply by
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d mul(Vector3d v, Vector3d dest) {
        dest.x = x * v.x;
        dest.y = y * v.y;
        dest.z = z * v.z;
        return dest;
    }

    /**
     * Divide this Vector3d component-wise by another Vector3d.
     *
     * @param v
     *          the vector to divide by
     * @return this
     */
    public Vector3d div(Vector3d v) {
        x /= v.x;
        y /= v.y;
        z /= v.z;
        return this;
    }

    /**
     * Divide this Vector3d component-wise by another Vector3f.
     *
     * @param v
     *          the vector to divide by
     * @return this
     */
    public Vector3d div(Vector3f v) {
        x /= v.x;
        y /= v.y;
        z /= v.z;
        return this;
    }

    /**
     * Divide this Vector3d component-wise by another Vector3f and store the result in dest.
     *
     * @param v
     *          the vector to divide by
     * @param dest
     * 			will hold the result
     * @return dest
     */
    public Vector3d div(Vector3f v, Vector3d dest) {
        dest.x = x / v.x;
        dest.y = y / v.y;
        dest.z = z / v.z;
        return dest;
    }

    /**
     * Divide this by v component-wise and store the result into dest.
     *
     * @param v
     *          the vector to divide by
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d div(Vector3d v, Vector3d dest) {
        dest.x = x / v.x;
        dest.y = y / v.y;
        dest.z = z / v.z;
        return dest;
    }

    /**
     * Multiply this Vector3d by the given matrix mat, perform perspective division
     * and store the result in dest.
     *

     * This method uses <tt>w=1.0</tt> as the fourth vector component.
     *
     * @param mat
     *          the matrix to multiply this vector by
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d mulProject(Matrix4d mat, Vector3d dest) {
        double invW = 1.0 / (mat.m03 * x + mat.m13 * y + mat.m23 * z + mat.m33);
        dest.set((mat.m00 * x + mat.m10 * y + mat.m20 * z + mat.m30) * invW,
                 (mat.m01 * x + mat.m11 * y + mat.m21 * z + mat.m31) * invW,
                 (mat.m02 * x + mat.m12 * y + mat.m22 * z + mat.m32) * invW);
        return dest;
    }

    /**
     * Multiply this Vector3d by the given matrix mat, perform perspective division.
     *

     * This method uses <tt>w=1.0</tt> as the fourth vector component.
     *
     * @param mat
     *          the matrix to multiply this vector by
     * @return this
     */
    public Vector3d mulProject(Matrix4d mat) {
        return mulProject(mat, this);
    }

    /**
     * Multiply this Vector3d by the given matrix mat, perform perspective division
     * and store the result in dest.
     *

     * This method uses <tt>w=1.0</tt> as the fourth vector component.
     *
     * @param mat
     *          the matrix to multiply this vector by
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d mulProject(Matrix4f mat, Vector3d dest) {
        double invW = 1.0 / (mat.m03 * x + mat.m13 * y + mat.m23 * z + mat.m33);
        dest.set((mat.m00 * x + mat.m10 * y + mat.m20 * z + mat.m30) * invW,
                 (mat.m01 * x + mat.m11 * y + mat.m21 * z + mat.m31) * invW,
                 (mat.m02 * x + mat.m12 * y + mat.m22 * z + mat.m32) * invW);
        return dest;
    }

    /**
     * Multiply this Vector3d by the given matrix mat, perform perspective division.
     *

     * This method uses <tt>w=1.0</tt> as the fourth vector component.
     *
     * @param mat
     *          the matrix to multiply this vector by
     * @return this
     */
    public Vector3d mulProject(Matrix4f mat) {
        return mulProject(mat, this);
    }

    /**
     * Multiply this Vector3d by the given matrix mat.
     *
     * @param mat
     *          the matrix to multiply this vector by
     * @return this
     */
    public Vector3d mul(Matrix3f mat) {
        return mul(mat, this);
    }

    /**
     * Multiply this Vector3d by the given matrix mat.
     *
     * @param mat
     *          the matrix to multiply this vector by
     * @return this
     */
    public Vector3d mul(Matrix3d mat) {
        return mul(mat, this);
    }

    /**
     * Multiply this by the given matrix mat and store the
     * result in dest.
     *
     * @param mat
     *          the matrix to multiply this vector by
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d mul(Matrix3d mat, Vector3d dest) {
        dest.set(mat.m00 * x + mat.m10 * y + mat.m20 * z,
                 mat.m01 * x + mat.m11 * y + mat.m21 * z,
                 mat.m02 * x + mat.m12 * y + mat.m22 * z);
        return dest;
    }

    /**
     * Multiply this by the given matrix mat and store the
     * result in dest.
     *
     * @param mat
     *          the matrix to multiply this vector by
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d mul(Matrix3f mat, Vector3d dest) {
        dest.set(mat.m00 * x + mat.m10 * y + mat.m20 * z,
                 mat.m01 * x + mat.m11 * y + mat.m21 * z,
                 mat.m02 * x + mat.m12 * y + mat.m22 * z);
        return dest;
    }

    /**
     * Multiply this by the given 4x4 matrix mat.
     *

     * This method assumes the <tt>w</tt> component of this to be <tt>1.0</tt>.
     *
     * @param mat
     *          the matrix to multiply this vector by
     * @return this
     */
    public Vector3d mulPoint(Matrix4f mat) {
        return mulPoint(mat, this);
    }

    /**
     * Multiply this by the given 4x4 matrix mat.
     *

     * This method assumes the <tt>w</tt> component of this to be <tt>1.0</tt>.
     *
     * @param mat
     *          the matrix to multiply this vector by
     * @return this
     */
    public Vector3d mulPoint(Matrix4d mat) {
        return mulPoint(mat, this);
    }

    /**
     * Multiply this by the given 4x4 matrix mat and store the
     * result in dest.
     *

     * This method assumes the <tt>w</tt> component of this to be <tt>1.0</tt>.
     *
     * @param mat
     *          the matrix to multiply this vector by
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d mulPoint(Matrix4d mat, Vector3d dest) {
        dest.set(mat.m00 * x + mat.m10 * y + mat.m20 * z + mat.m30,
                 mat.m01 * x + mat.m11 * y + mat.m21 * z + mat.m31,
                 mat.m02 * x + mat.m12 * y + mat.m22 * z + mat.m32);
        return dest;
    }

    /**
     * Multiply this by the given 4x4 matrix mat and store the
     * result in dest.
     *

     * This method assumes the <tt>w</tt> component of this to be <tt>1.0</tt>.
     *
     * @param mat
     *          the matrix to multiply this vector by
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d mulPoint(Matrix4f mat, Vector3d dest) {
        dest.set(mat.m00 * x + mat.m10 * y + mat.m20 * z + mat.m30,
                 mat.m01 * x + mat.m11 * y + mat.m21 * z + mat.m31,
                 mat.m02 * x + mat.m12 * y + mat.m22 * z + mat.m32);
        return dest;
    }

    /**
     * Multiply this by the given 4x4 matrix mat.
     *

     * This method assumes the <tt>w</tt> component of this to be <tt>0.0</tt>.
     *
     * @param mat
     *          the matrix to multiply this vector by
     * @return this
     */
    public Vector3d mulDirection(Matrix4f mat) {
        return mulDirection(mat, this);
    }

    /**
     * Multiply this by the given 4x4 matrix mat.
     *

     * This method assumes the <tt>w</tt> component of this to be <tt>0.0</tt>.
     *
     * @param mat
     *          the matrix to multiply this vector by
     * @return this
     */
    public Vector3d mulDirection(Matrix4d mat) {
        return mulDirection(mat, this);
    }

    /**
     * Multiply this by the given 4x4 matrix mat and store the
     * result in dest.
     *

     * This method assumes the <tt>w</tt> component of this to be <tt>0.0</tt>.
     *
     * @param mat
     *          the matrix to multiply this vector by
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d mulDirection(Matrix4d mat, Vector3d dest) {
        dest.set(mat.m00 * x + mat.m10 * y + mat.m20 * z,
                 mat.m01 * x + mat.m11 * y + mat.m21 * z,
                 mat.m02 * x + mat.m12 * y + mat.m22 * z);
        return dest;
    }

    /**
     * Multiply this by the given 4x4 matrix mat and store the
     * result in dest.
     *

     * This method assumes the <tt>w</tt> component of this to be <tt>0.0</tt>.
     *
     * @param mat
     *          the matrix to multiply this vector by
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d mulDirection(Matrix4f mat, Vector3d dest) {
        dest.set(mat.m00 * x + mat.m10 * y + mat.m20 * z,
                 mat.m01 * x + mat.m11 * y + mat.m21 * z,
                 mat.m02 * x + mat.m12 * y + mat.m22 * z);
        return dest;
    }

    /**
     * Multiply this Vector3d by the given scalar value.
     *
     * @param scalar
     *          the scalar to multiply this vector by
     * @return this
     */
    public Vector3d mul(double scalar) {
        x *= scalar;
        y *= scalar;
        z *= scalar;
        return this;
    }

    /**
     * Multiply this Vector3d by the given scalar value and store the result in dest.
     *
     * @param scalar
     *          the scalar factor
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d mul(double scalar, Vector3d dest) {
        dest.x = x * scalar;
        dest.y = y * scalar;
        dest.z = z * scalar;
        return dest;
    }

    /**
     * Multiply the components of this Vector3f by the given scalar values and store the result in this.
     *
     * @param x
     *          the x component to multiply this vector by
     * @param y
     *          the y component to multiply this vector by
     * @param z
     *          the z component to multiply this vector by
     * @return this
     */
    public Vector3d mul(double x, double y, double z) {
        this.x *= x;
        this.y *= y;
        this.z *= z;
        return this;
    }

    /**
     * Multiply the components of this Vector3f by the given scalar values and store the result in dest.
     *
     * @param x
     *          the x component to multiply this vector by
     * @param y
     *          the y component to multiply this vector by
     * @param z
     *          the z component to multiply this vector by
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d mul(double x, double y, double z, Vector3d dest) {
        dest.x = this.x * x;
        dest.y = this.y * y;
        dest.z = this.z * z;
        return dest;
    }

    /**
     * Rotate this vector by the given quaternion quat and store the result in this.
     *
     * @see Quaterniond#transform(Vector3d)
     *
     * @param quat
     *          the quaternion to rotate this vector
     * @return this
     */
    public Vector3d rotate(Quaterniond quat) {
        quat.transform(this, this);
        return this;
    }

    /**
     * Rotate this vector by the given quaternion quat and store the result in dest.
     *
     * @see Quaterniond#transform(Vector3d)
     *
     * @param quat
     *          the quaternion to rotate this vector
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d rotate(Quaterniond quat, Vector3d dest) {
        quat.transform(this, dest);
        return dest;
    }

    /**
     * Divide this Vector3d by the given scalar value.
     *
     * @param scalar
     *          the scalar to divide this vector by
     * @return this
     */
    public Vector3d div(double scalar) {
        x /= scalar;
        y /= scalar;
        z /= scalar;
        return this;
    }

    /**
     * Divide this Vector3d by the given scalar value and store the result in dest.
     *
     * @param scalar
     *          the scalar to divide this vector by
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d div(double scalar, Vector3d dest) {
        dest.x = x / scalar;
        dest.y = y / scalar;
        dest.z = z / scalar;
        return dest;
    }

    /**
     * Divide the components of this Vector3f by the given scalar values and store the result in this.
     *
     * @param x
     *          the x component to divide this vector by
     * @param y
     *          the y component to divide this vector by
     * @param z
     *          the z component to divide this vector by
     * @return this
     */
    public Vector3d div(double x, double y, double z) {
        this.x /= x;
        this.y /= y;
        this.z /= z;
        return this;
    }

    /**
     * Divide the components of this Vector3f by the given scalar values and store the result in dest.
     *
     * @param x
     *          the x component to divide this vector by
     * @param y
     *          the y component to divide this vector by
     * @param z
     *          the z component to divide this vector by
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d div(double x, double y, double z, Vector3d dest) {
        dest.x = this.x / x;
        dest.y = this.y / y;
        dest.z = this.z / z;
        return dest;
    }

    /**
     * Multiply v by the scalar value and store the result in dest.
     *
     * @param v
     *          the vector to multiply
     * @param scalar
     *          the scalar to multiply the given vector by
     * @param dest
     *          will hold the result
     */
    public static void mul(Vector3f v, double scalar, Vector3d dest) {
        dest.x = v.x * scalar;
        dest.y = v.y * scalar;
        dest.z = v.z * scalar;
    }

    /**
     * Return the length squared of this vector.
     *
     * @return the length squared
     */
    public double lengthSquared() {
        return x * x + y * y + z * z;
    }

    /**
     * Return the length of this vector.
     *
     * @return the length
     */
    public double length() {
        return Math.sqrt(lengthSquared());
    }

    /**
     * Normalize this vector.
     *
     * @return this
     */
    public Vector3d normalize() {
        double invLength = 1.0 / length();
        x *= invLength;
        y *= invLength;
        z *= invLength;
        return this;
    }

    /**
     * Normalize this vector and store the result in dest.
     *
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d normalize(Vector3d dest) {
        double invLength = 1.0 / length();
        dest.x = x * invLength;
        dest.y = y * invLength;
        dest.z = z * invLength;
        return dest;
    }

    /**
     * Set this vector to be the cross product of this and v2.
     *
     * @param v
     *          the other vector
     * @return this
     */
    public Vector3d cross(Vector3d v) {
        set(y * v.z - z * v.y,
            z * v.x - x * v.z,
            x * v.y - y * v.x);
        return this;
    }

    /**
     * Set this vector to be the cross product of itself and <tt>(x, y, z)</tt>.
     *
     * @param x
     *          the x component of the other vector
     * @param y
     *          the y component of the other vector
     * @param z
     *          the z component of the other vector
     * @return this
     */
    public Vector3d cross(double x, double y, double z) {
        return set(this.y * z - this.z * y,
                   this.z * x - this.x * z,
                   this.x * y - this.y * x);
    }

    /**
     * Calculate the cross product of this and v2 and store the result in dest.
     *
     * @param v
     *          the other vector
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d cross(Vector3d v, Vector3d dest) {
        dest.set(y * v.z - z * v.y,
                 z * v.x - x * v.z,
                 x * v.y - y * v.x);
        return dest;
    }

    /**
     * Compute the cross product of this vector and <tt>(x, y, z)</tt> and store the result in dest.
     *
     * @param x
     *          the x component of the other vector
     * @param y
     *          the y component of the other vector
     * @param z
     *          the z component of the other vector
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d cross(double x, double y, double z, Vector3d dest) {
        return dest.set(this.y * z - this.z * y,
                        this.z * x - this.x * z,
                        this.x * y - this.y * x);
    }

    /**
     * Return the distance between this vector and v.
     *
     * @param v
     *          the other vector
     * @return the distance
     */
    public double distance(Vector3d v) {
        double dx = v.x - x;
        double dy = v.y - y;
        double dz = v.z - z;
        return Math.sqrt(dx * dx + dy * dy + dz * dz);
    }

    /**
     * Return the distance between this vector and <tt>(x, y, z)</tt>.
     *
     * @param x
     *          the x component of the other vector
     * @param y
     *          the y component of the other vector
     * @param z
     *          the z component of the other vector
     * @return the euclidean distance
     */
    public double distance(double x, double y, double z) {
        double dx = this.x - x;
        double dy = this.y - y;
        double dz = this.z - z;
        return Math.sqrt(dx * dx + dy * dy + dz * dz);
    }

    /**
     * Return the square of the distance between this vector and v.
     *
     * @param v
     *          the other vector
     * @return the squared of the distance
     */
    public double distanceSquared(Vector3d v) {
        double dx = v.x - x;
        double dy = v.y - y;
        double dz = v.z - z;
        return dx * dx + dy * dy + dz * dz;
    }

    /**
     * Return the square of the distance between this vector and <tt>(x, y, z)</tt>.
     *
     * @param x
     *          the x component of the other vector
     * @param y
     *          the y component of the other vector
     * @param z
     *          the z component of the other vector
     * @return the square of the distance
     */
    public double distanceSquared(double x, double y, double z) {
        double dx = this.x - x;
        double dy = this.y - y;
        double dz = this.z - z;
        return dx * dx + dy * dy + dz * dz;
    }

    /**
     * Return the dot product of this vector and the supplied vector.
     *
     * @param v
     *          the other vector
     * @return the dot product
     */
    public double dot(Vector3d v) {
        return x * v.x + y * v.y + z * v.z;
    }

    /**
     * Return the dot product of this vector and the vector <tt>(x, y, z)</tt>.
     *
     * @param x
     *          the x component of the other vector
     * @param y
     *          the y component of the other vector
     * @param z
     *          the z component of the other vector
     * @return the dot product
     */
    public double dot(double x, double y, double z) {
        return this.x * x + this.y * y + this.z * z;
    }

    /**
     * Return the cosine of the angle between this vector and
     * the supplied vector. Use this instead of <tt>Math.cos(angle(v))</tt>.
     *
     * @see #angle(Vector3d)
     *
     * @param v
     *          the other vector
     * @return the cosine of the angle
     */
    public double angleCos(Vector3d v) {
        double length1Sqared = x * x + y * y + z * z;
        double length2Sqared = v.x * v.x + v.y * v.y + v.z * v.z;
        double dot = x * v.x + y * v.y + z * v.z;
        return dot / (Math.sqrt(length1Sqared * length2Sqared));
    }

    /**
     * Return the angle between this vector and the supplied vector.
     *
     * @see #angleCos(Vector3d)
     *
     * @param v
     *          the other vector
     * @return the angle, in radians
     */
    public double angle(Vector3d v) {
        double cos = angleCos(v);
        // This is because sometimes cos goes above 1 or below -1 because of lost precision
        cos = Math.min(cos, 1);
        cos = Math.max(cos, -1);
        return Math.acos(cos);
    }

    /**
     * Set all components to zero.
     *
     * @return this
     */
    public Vector3d zero() {
        x = 0.0;
        y = 0.0;
        z = 0.0;
        return this;
    }

    /**
     * Return a string representation of this vector.
     *

     * This method creates a new {@link DecimalFormat} on every invocation with the format string "<tt> 0.000E0;-</tt>".
     *
     * @return the string representation
     */
    public String toString() {
        DecimalFormat formatter = new DecimalFormat(" 0.000E0;-"); //$NON-NLS-1$
        return toString(formatter).replaceAll("E(\\d+)", "E+$1"); //$NON-NLS-1$ //$NON-NLS-2$
    }

    /**
     * Return a string representation of this vector by formatting the vector components with the given {@link NumberFormat}.
     *
     * @param formatter
     *          the {@link NumberFormat} used to format the vector components with
     * @return the string representation
     */
    public String toString(NumberFormat formatter) {
        return "(" + formatter.format(x) + " " + formatter.format(y) + " " + formatter.format(z) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    }

    public void writeExternal(ObjectOutput out) throws IOException {
        out.writeDouble(x);
        out.writeDouble(y);
        out.writeDouble(z);
    }

    public void readExternal(ObjectInput in) throws IOException,
            ClassNotFoundException {
        x = in.readDouble();
        y = in.readDouble();
        z = in.readDouble();
    }

    /**
     * Negate this vector.
     *
     * @return this
     */
    public Vector3d negate() {
        x = -x;
        y = -y;
        z = -z;
        return this;
    }

    /**
     * Negate this vector and store the result in dest.
     *
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d negate(Vector3d dest) {
        dest.x = -x;
        dest.y = -y;
        dest.z = -z;
        return dest;
    }

    public int hashCode() {
        final int prime = 31;
        int result = 1;
        long temp;
        temp = Double.doubleToLongBits(x);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        temp = Double.doubleToLongBits(y);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        temp = Double.doubleToLongBits(z);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        return result;
    }

    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Vector3d other = (Vector3d) obj;
        if (Double.doubleToLongBits(x) != Double.doubleToLongBits(other.x))
            return false;
        if (Double.doubleToLongBits(y) != Double.doubleToLongBits(other.y))
            return false;
        if (Double.doubleToLongBits(z) != Double.doubleToLongBits(other.z))
            return false;
        return true;
    }

    /**
     * Reflect this vector about the given normal vector.
     *
     * @param normal
     *          the vector to reflect about
     * @return this
     */
    public Vector3d reflect(Vector3d normal) {
        double dot = this.dot(normal);
        x = x - 2.0 * dot * normal.x;
        y = y - 2.0 * dot * normal.y;
        z = z - 2.0 * dot * normal.z;
        return this;
    }

    /**
     * Reflect this vector about the given normal vector.
     *
     * @param x
     *          the x component of the normal
     * @param y
     *          the y component of the normal
     * @param z
     *          the z component of the normal
     * @return this
     */
    public Vector3d reflect(double x, double y, double z) {
        double dot = this.dot(x, y, z);
        this.x = this.x - 2.0 * dot * x;
        this.y = this.y - 2.0 * dot * y;
        this.z = this.z - 2.0 * dot * z;
        return this;
    }

    /**
     * Reflect this vector about the given normal vector and store the result in dest.
     *
     * @param normal
     *          the vector to reflect about
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d reflect(Vector3d normal, Vector3d dest) {
        double dot = this.dot(normal);
        dest.x = x - 2.0 * dot * normal.x;
        dest.y = y - 2.0 * dot * normal.y;
        dest.z = z - 2.0 * dot * normal.z;
        return dest;
    }

    /**
     * Reflect this vector about the given normal vector and store the result in dest.
     *
     * @param x
     *          the x component of the normal
     * @param y
     *          the y component of the normal
     * @param z
     *          the z component of the normal
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d reflect(double x, double y, double z, Vector3d dest) {
        double dot = this.dot(x, y, z);
        dest.x = this.x - 2.0 * dot * x;
        dest.y = this.y - 2.0 * dot * y;
        dest.z = this.z - 2.0 * dot * z;
        return dest;
    }

    /**
     * Compute the half vector between this and the other vector.
     *
     * @param other
     *          the other vector
     * @return this
     */
    public Vector3d half(Vector3d other) {
        return this.add(other).normalize();
    }

    /**
     * Compute the half vector between this and the vector <tt>(x, y, z)</tt>.
     *
     * @param x
     *          the x component of the other vector
     * @param y
     *          the y component of the other vector
     * @param z
     *          the z component of the other vector
     * @return this
     */
    public Vector3d half(double x, double y, double z) {
        return this.add(x, y, z).normalize();
    }

    /**
     * Compute the half vector between this and the other vector and store the result in dest.
     *
     * @param other
     *          the other vector
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d half(Vector3d other, Vector3d dest) {
        return dest.set(this).add(other).normalize();
    }

    /**
     * Compute the half vector between this and the vector <tt>(x, y, z)</tt>
     * and store the result in dest.
     *
     * @param x
     *          the x component of the other vector
     * @param y
     *          the y component of the other vector
     * @param z
     *          the z component of the other vector
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d half(double x, double y, double z, Vector3d dest) {
        return dest.set(this).add(x, y, z).normalize();
    }

    /**
     * Compute a smooth-step (i.e. hermite with zero tangents) interpolation
     * between this vector and the given vector v and
     * store the result in dest.
     *
     * @param v
     *          the other vector
     * @param t
     *          the interpolation factor, within <tt>[0..1]</tt>
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d smoothStep(Vector3d v, double t, Vector3d dest) {
        double t2 = t * t;
        double t3 = t2 * t;
        dest.x = (2.0 * x - 2.0 * v.x) * t3 + (3.0 * v.x - 3.0 * x) * t2 + x * t + x;
        dest.y = (2.0 * y - 2.0 * v.y) * t3 + (3.0 * v.y - 3.0 * y) * t2 + y * t + y;
        dest.z = (2.0 * z - 2.0 * v.z) * t3 + (3.0 * v.z - 3.0 * z) * t2 + z * t + z;
        return dest;
    }

    /**
     * Compute a hermite interpolation between this vector and its
     * associated tangent t0 and the given vector v
     * with its tangent t1 and store the result in
     * dest.
     *
     * @param t0
     *          the tangent of this vector
     * @param v1
     *          the other vector
     * @param t1
     *          the tangent of the other vector
     * @param t
     *          the interpolation factor, within <tt>[0..1]</tt>
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d hermite(Vector3d t0, Vector3d v1, Vector3d t1, double t, Vector3d dest) {
        double t2 = t * t;
        double t3 = t2 * t;
        dest.x = (2.0 * x - 2.0 * v1.x + t1.x + t0.x) * t3 + (3.0 * v1.x - 3.0 * x - 2.0 * t0.x - t1.x) * t2 + x * t + x;
        dest.y = (2.0 * y - 2.0 * v1.y + t1.y + t0.y) * t3 + (3.0 * v1.y - 3.0 * y - 2.0 * t0.y - t1.y) * t2 + y * t + y;
        dest.z = (2.0 * z - 2.0 * v1.z + t1.z + t0.z) * t3 + (3.0 * v1.z - 3.0 * z - 2.0 * t0.z - t1.z) * t2 + z * t + z;
        return dest;
    }

    /**
     * Linearly interpolate this and other using the given interpolation factor t
     * and store the result in this.
     *

     * If t is <tt>0.0</tt> then the result is this. If the interpolation factor is 1.0
     * then the result is other.
     *
     * @param other
     *          the other vector
     * @param t
     *          the interpolation factor between 0.0 and 1.0
     * @return this
     */
    public Vector3d lerp(Vector3d other, double t) {
        return lerp(other, t, this);
    }

    /**
     * Linearly interpolate this and other using the given interpolation factor t
     * and store the result in dest.
     *

     * If t is <tt>0.0</tt> then the result is this. If the interpolation factor is 1.0
     * then the result is other.
     *
     * @param other
     *          the other vector
     * @param t
     *          the interpolation factor between 0.0 and 1.0
     * @param dest
     *          will hold the result
     * @return dest
     */
    public Vector3d lerp(Vector3d other, double t, Vector3d dest) {
        dest.x = (1.0 - t) * x + t * other.x;
        dest.y = (1.0 - t) * y + t * other.y;
        dest.z = (1.0 - t) * z + t * other.z;
        return dest;
    }

}


text:
namespace llvm
{
class Type;
}

struct code_location
{
    file_position pos;
    std::size_t file_id;
};
typedef boost::variant<boost::blank, code_location> error_location;

inline error_location to_error_location(const node_source& src)
{
    return visit<error_location>(src,
    [&](boost::blank)
    {
        return boost::blank();
    },
    [&](const file_source& src)
    {
        return code_location{src.begin, src.file_id};
    });
}
template<class T>
inline error_location to_error_location(T&& obj)
{
    return std::forward<T>(obj);
}

typedef boost::variant<boost::blank, std::size_t, std::string, llvm::Type&> error_parameter;

struct compile_exception
  : std::exception
{
    template<class Location, class... ParamTypes>
    compile_exception(error_kind kind, std::size_t error_id, const Location& location, ParamTypes&&... params)
      : kind{kind},
        error_id{error_id},
        location{to_error_location(location)},
        params{std::forward<ParamTypes>(params)...}
    {}

#ifndef NDEBUG
    const char* what() const noexcept override;
    // implemented in printing.cpp
    // 'leaks' memory (freed when program terminates)
#endif

    error_kind kind;
    std::size_t error_id;
    error_location location;
    std::vector<error_parameter> params;
};

struct not_implemented
  : std::runtime_error
{
    using std::runtime_error::runtime_error;
};

#endif


text:
@class DVTDocumentLocation, DVTFileDataType, IDEFileReference, IDELogNavigatorItem, NSDate, NSImage, NSString;

@interface IDELogNavigatorLoadMoreItem : NSObject <IDEKeyDrivenNavigableItemRepresentedObject>
{
    NSImage *_refreshImage;
    NSString *_navigableItem_name;
    NSString *_subtitle;
    long long _navigableItem_progressValue;
    unsigned long long _count;
    id _firstItem;
    NSDate *_loadMoreStartDate;
    IDELogNavigatorItem *_logNavigatorItem;
    unsigned long long _additionalCount;
}

@property(nonatomic) unsigned long long additionalCount; // @synthesize additionalCount=_additionalCount;
@property(retain, nonatomic) IDELogNavigatorItem *logNavigatorItem; // @synthesize logNavigatorItem=_logNavigatorItem;
@property(readonly, nonatomic) NSDate *loadMoreStartDate; // @synthesize loadMoreStartDate=_loadMoreStartDate;
@property(retain, nonatomic) id firstItem; // @synthesize firstItem=_firstItem;
@property(readonly, nonatomic) unsigned long long count; // @synthesize count=_count;
@property(nonatomic) long long navigableItem_progressValue; // @synthesize navigableItem_progressValue=_navigableItem_progressValue;
@property(retain, nonatomic) NSString *subtitle; // @synthesize subtitle=_subtitle;
@property(retain, nonatomic) NSString *navigableItem_name; // @synthesize navigableItem_name=_navigableItem_name;
- (void)loadMore;
@property(readonly) DVTFileDataType *navigableItem_documentType;
@property(readonly) DVTDocumentLocation *navigableItem_contentDocumentLocation;
- (unsigned long long)result;
- (long long)currentStep;
- (void)update;
- (long long)progress;
@property(readonly, nonatomic) NSImage *navigableItem_image;
- (id)identifier;
- (id)initWithLogNavigatorItem:(id)arg1 additionalCount:(unsigned long long)arg2;

// Remaining properties
@property(readonly, copy) NSString *debugDescription;
@property(readonly, copy) NSString *description;
@property(readonly) unsigned long long hash;
@property(readonly) IDEFileReference *navigableItem_fileReference;
@property(readonly) NSString *navigableItem_groupIdentifier;
@property(readonly) BOOL navigableItem_isLeaf;
@property(readonly) BOOL navigableItem_isMajorGroup;
@property(readonly) NSString *navigableItem_toolTip;
@property(readonly) Class superclass;

@end