text:
#include "modules/rtp_rtcp/mocks/mock_rtcp_bandwidth_observer.h"

namespace webrtc {

MockRtcpBandwidthObserver::MockRtcpBandwidthObserver() = default;
MockRtcpBandwidthObserver::~MockRtcpBandwidthObserver() = default;

}  // namespace webrtc

redpajama_set_name: RedPajamaGithub


text:
#ifndef WEBRTC_API_VIDEO_VIDEO_FRAME_H_
#define WEBRTC_API_VIDEO_VIDEO_FRAME_H_

#include <stdint.h>

#include "webrtc/api/video/video_rotation.h"
#include "webrtc/api/video/video_frame_buffer.h"

namespace webrtc {

class VideoFrame {
 public:
  // TODO(nisse): This constructor is consistent with the now deleted
  // cricket::WebRtcVideoFrame. We should consider whether or not we
  // want to stick to this style and deprecate the other constructor.
  VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
             webrtc::VideoRotation rotation,
             int64_t timestamp_us);

  // Preferred constructor.
  VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
             uint32_t timestamp,
             int64_t render_time_ms,
             VideoRotation rotation);

  ~VideoFrame();

  // Support move and copy.
  VideoFrame(const VideoFrame&);
  VideoFrame(VideoFrame&&);
  VideoFrame& operator=(const VideoFrame&);
  VideoFrame& operator=(VideoFrame&&);

  // Get frame width.
  int width() const;
  // Get frame height.
  int height() const;
  // Get frame size in pixels.
  uint32_t size() const;

  // System monotonic clock, same timebase as rtc::TimeMicros().
  int64_t timestamp_us() const { return timestamp_us_; }
  void set_timestamp_us(int64_t timestamp_us) { timestamp_us_ = timestamp_us; }

  // TODO(nisse): After the cricket::VideoFrame and webrtc::VideoFrame
  // merge, timestamps other than timestamp_us will likely be
  // deprecated.

  // Set frame timestamp (90kHz).
  void set_timestamp(uint32_t timestamp) { timestamp_rtp_ = timestamp; }

  // Get frame timestamp (90kHz).
  uint32_t timestamp() const { return timestamp_rtp_; }

  // For now, transport_frame_id and rtp timestamp are the same.
  // TODO(nisse): Must be handled differently for QUIC.
  uint32_t transport_frame_id() const { return timestamp(); }

  // Set capture ntp time in milliseconds.
  // TODO(nisse): Deprecated. Migrate all users to timestamp_us().
  void set_ntp_time_ms(int64_t ntp_time_ms) { ntp_time_ms_ = ntp_time_ms; }

  // Get capture ntp time in milliseconds.
  // TODO(nisse): Deprecated. Migrate all users to timestamp_us().
  int64_t ntp_time_ms() const { return ntp_time_ms_; }

  // Naming convention for Coordination of Video Orientation. Please see
  // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126114v120700p.pdf
  //
  // "pending rotation" or "pending" = a frame that has a VideoRotation > 0.
  //
  // "not pending" = a frame that has a VideoRotation == 0.
  //
  // "apply rotation" = modify a frame from being "pending" to being "not
  //                    pending" rotation (a no-op for "unrotated").
  //
  VideoRotation rotation() const { return rotation_; }
  void set_rotation(VideoRotation rotation) { rotation_ = rotation; }

  // Get render time in milliseconds.
  // TODO(nisse): Deprecated. Migrate all users to timestamp_us().
  int64_t render_time_ms() const;

  // Return the underlying buffer. Never nullptr for a properly
  // initialized VideoFrame.
  rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer() const;

  // TODO(nisse): Deprecated.
  // Return true if the frame is stored in a texture.
  bool is_texture() const {
    return video_frame_buffer()->type() == VideoFrameBuffer::Type::kNative;
  }

 private:
  // An opaque reference counted handle that stores the pixel data.
  rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_;
  uint32_t timestamp_rtp_;
  int64_t ntp_time_ms_;
  int64_t timestamp_us_;
  VideoRotation rotation_;
};

}  // namespace webrtc

#endif  // WEBRTC_API_VIDEO_VIDEO_FRAME_H_


text:
define(function() {
    // list of menus. Each item will be converted to <a> link.
    // It's key will become its href, and value its text.
    return [
        {href:'/', text:'Home'},
        {href: '/accommodation', text: 'Accommodation'},
        {href: '/location', text: 'Location'},
        {href: '/tours-around-kyrgyzstan', text: 'Tours around Kyrgyzstan!'},
        {href: '/contacts', text: 'Contacts'}
    ];
});


text:
class RailgunContent::ComponentsController < Railgun::ResourcesController

  def self.inherited(base)
    super(base)
    RailgunContent.application.add_component(base)
  end

end


text:
layout: blog_by_tag
tag: amelioration-continue
permalink: /blog/tag/amelioration-continue/
---


text:
package org.camunda.bpm.engine.rest;

import static javax.ws.rs.core.Response.Status;
import static io.restassured.RestAssured.expect;
import static io.restassured.RestAssured.given;
import static io.restassured.path.json.JsonPath.from;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.camunda.bpm.engine.FilterService;
import org.camunda.bpm.engine.filter.Filter;
import org.camunda.bpm.engine.filter.FilterQuery;
import org.camunda.bpm.engine.impl.AbstractQuery;
import org.camunda.bpm.engine.rest.dto.runtime.FilterQueryDto;
import org.camunda.bpm.engine.rest.helper.MockProvider;
import org.camunda.bpm.engine.rest.util.container.TestContainerRule;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.mockito.InOrder;

import io.restassured.response.Response;

/**
 * @author Sebastian Menski
 */
public class FilterRestServiceQueryTest extends AbstractRestServiceTest {

  @ClassRule
  public static TestContainerRule rule = new TestContainerRule();

  protected static final String FILTER_QUERY_URL = TEST_RESOURCE_ROOT_PATH + FilterRestService.PATH;
  protected static final String SINGLE_FILTER_URL = FILTER_QUERY_URL + "/{id}";
  protected static final String FILTER_COUNT_QUERY_URL = FILTER_QUERY_URL + "/count";

  protected FilterQuery mockedQuery;
  protected Filter mockedFilter;
  protected int mockedFilterItemCount;
  protected Filter anotherMockedFilter;
  protected int anotherMockedFilterItemCount;

  @Before
  public void setUpRuntimeData() {
    mockedQuery = MockProvider.createMockFilterQuery();
    mockedFilter = MockProvider.createMockFilter(MockProvider.EXAMPLE_FILTER_ID);
    mockedFilterItemCount = 13;
    anotherMockedFilter = MockProvider.createMockFilter(MockProvider.ANOTHER_EXAMPLE_FILTER_ID);
    anotherMockedFilterItemCount = 42;

    FilterService filterService = processEngine.getFilterService();

    when(filterService.createFilterQuery()).thenReturn(mockedQuery);
    when(filterService.getFilter(eq(MockProvider.EXAMPLE_FILTER_ID))).thenReturn(mockedFilter);
    when(filterService.count(eq(MockProvider.EXAMPLE_FILTER_ID))).thenReturn((long) mockedFilterItemCount);
    when(filterService.getFilter(eq(MockProvider.ANOTHER_EXAMPLE_FILTER_ID))).thenReturn(anotherMockedFilter);
    when(filterService.count(eq(MockProvider.ANOTHER_EXAMPLE_FILTER_ID))).thenReturn((long) anotherMockedFilterItemCount);
  }

  @Test
  public void testEmptyQuery() {
    String queryFilterId = "";

    given()
      .queryParam("filterId", queryFilterId)
    .then().expect()
      .statusCode(Status.OK.getStatusCode())
    .when()
      .get(FILTER_QUERY_URL);

    verify(mockedQuery).list();
  }

  @Test
  public void testNoParametersQuery() {
    expect()
      .statusCode(Status.OK.getStatusCode())
    .when()
      .get(FILTER_QUERY_URL);

    verify(mockedQuery).list();
    verifyNoMoreInteractions(mockedQuery);
  }

  @Test
  public void testCountyQuery() {
    expect()
      .statusCode(Status.OK.getStatusCode())
      .body("count", equalTo(2))
    .when()
      .get(FILTER_COUNT_QUERY_URL);

    verify(mockedQuery).count();
    verifyNoMoreInteractions(mockedQuery);
  }

  @Test
  public void testFilterRetrieval() {
    Response response = given()
      .queryParam("filterId", MockProvider.EXAMPLE_FILTER_ID)
    .then().expect()
      .statusCode(Status.OK.getStatusCode())
    .when()
      .get(FILTER_QUERY_URL);

    verifyFilterMock(response);
  }

  @Test
  public void testMultipleParameters() {
    given()
      .queryParams(getQueryParameters())
    .then().expect()
      .statusCode(Status.OK.getStatusCode())
    .when()
      .get(FILTER_QUERY_URL);

    verifyQueryMockMultipleParameters();
  }

  @Test
  public void testInvalidSortingOptions() {
    executeAndVerifySorting("anInvalidSortByOption", "asc", Status.BAD_REQUEST);
    executeAndVerifySorting("filterId", "anInvalidSortOrderOption", Status.BAD_REQUEST);
  }

  @Test
  public void testSortByParameterOnly() {
    given()
      .queryParam("sortBy", "filterId")
    .then().expect()
      .statusCode(Status.BAD_REQUEST.getStatusCode())
    .when()
      .get(FILTER_QUERY_URL);
  }

  @Test
  public void testSortOrderParameterOnly() {
    given()
      .queryParam("sortOrder", "asc")
    .then().expect()
      .statusCode(Status.BAD_REQUEST.getStatusCode())
    .when()
      .get(FILTER_QUERY_URL);
  }

  @Test
  public void testSuccessfulPagination() {
    executeAndVerifyPagination(0, 10, Status.OK);
  }

  @Test
  public void testMissingFirstResultParameter() {
    executeAndVerifyPagination(null, 10, Status.OK);
  }

  @Test
  public void testMissingMaxResultsParameter() {
    executeAndVerifyPagination(0, null, Status.OK);
  }

  @Test
  public void testSingleFilterWithItemCount() {
    given()
      .pathParam("id", MockProvider.EXAMPLE_FILTER_ID)
      .queryParam("itemCount", true)
    .then().expect()
      .statusCode(Status.OK.getStatusCode())
      .body("containsKey('itemCount')", is(true))
      .body("itemCount", equalTo(mockedFilterItemCount))
    .when()
      .get(SINGLE_FILTER_URL);
  }

  @Test
  public void testSingleFilterWithoutItemCount() {
    given()
      .pathParam("id", MockProvider.EXAMPLE_FILTER_ID)
    .then().expect()
      .statusCode(Status.OK.getStatusCode())
      .body("containsKey('itemCount')", is(false))
    .when()
      .get(SINGLE_FILTER_URL);
  }

  @Test
  public void testFilterQueryWithItemCount() {
    given()
      .queryParam("itemCount", true)
    .then().expect()
      .statusCode(Status.OK.getStatusCode())
      .body("$.size", equalTo(2))
      .body("any { it.containsKey('itemCount') }", is(true))
      .body("[0].itemCount", equalTo(mockedFilterItemCount))
      .body("[1].itemCount", equalTo(anotherMockedFilterItemCount))
    .when()
      .get(FILTER_QUERY_URL);
  }

  @Test
  public void testFilterQueryWithoutItemCount() {
    given()
    .then().expect()
      .statusCode(Status.OK.getStatusCode())
      .body("$.size", equalTo(2))
      .body("any { it.containsKey('itemCount') }", is(false))
    .when()
      .get(FILTER_QUERY_URL);
  }

  protected Map<String, String> getQueryParameters() {
    Map<String, String> params = new HashMap<String, String>();

    params.put("filterId", MockProvider.EXAMPLE_FILTER_ID);
    params.put("resourceType", MockProvider.EXAMPLE_FILTER_RESOURCE_TYPE);
    params.put("name", MockProvider.EXAMPLE_FILTER_NAME);
    params.put("nameLike", MockProvider.EXAMPLE_FILTER_NAME);
    params.put("owner", MockProvider.EXAMPLE_FILTER_OWNER);

    return params;
  }

  @SuppressWarnings("unchecked")
  protected void verifyFilterMock(Response response) {
    InOrder inOrder = inOrder(mockedQuery);
    inOrder.verify(mockedQuery).filterId(MockProvider.EXAMPLE_FILTER_ID);
    inOrder.verify(mockedQuery).list();

    String content = response.asString();
    List<Map<String, String>> filters = from(content).getList("");

    assertThat(filters).hasSize(2);

    assertThat(filters.get(0)).isNotNull();

    String returnedFilterId = from(content).getString("[0].id");
    String returnedResourceType = from(content).getString("[0].resourceType");
    String returnedName = from(content).getString("[0].name");
    String returnedOwner = from(content).getString("[0].owner");
    Map<String, Object> returnedQuery = from(content).getJsonObject("[0].query");
    Map<String, Object> returnedProperties = from(content).getJsonObject("[0].properties");

    Map<String, String> expectedVariable = new HashMap<String, String>();
    expectedVariable.put("name", "foo");
    expectedVariable.put("value", "bar");
    expectedVariable.put("operator", "eq");

    assertThat(returnedFilterId).isEqualTo(MockProvider.EXAMPLE_FILTER_ID);
    assertThat(returnedResourceType).isEqualTo(MockProvider.EXAMPLE_FILTER_RESOURCE_TYPE);
    assertThat(returnedName).isEqualTo(MockProvider.EXAMPLE_FILTER_NAME);
    assertThat(returnedOwner).isEqualTo(MockProvider.EXAMPLE_FILTER_OWNER);
    assertThat(returnedQuery.get("name")).isEqualTo(MockProvider.EXAMPLE_FILTER_QUERY_DTO.getName());
    assertThat((List<Map<String, String>>) returnedQuery.get("processVariables")).hasSize(1).containsExactly(expectedVariable);
    assertThat((List<Map<String, String>>) returnedQuery.get("taskVariables")).hasSize(1).containsExactly(expectedVariable);
    assertThat((List<Map<String, String>>) returnedQuery.get("caseInstanceVariables")).hasSize(1).containsExactly(expectedVariable);
    assertThat(returnedProperties).isEqualTo(MockProvider.EXAMPLE_FILTER_PROPERTIES);

    assertThat(filters.get(1)).isNotNull();

    returnedFilterId = from(content).getString("[1].id");
    returnedResourceType = from(content).getString("[1].resourceType");
    returnedName = from(content).getString("[1].name");
    returnedOwner = from(content).getString("[1].owner");
    returnedQuery = from(content).getJsonObject("[1].query");
    returnedProperties = from(content).getJsonObject("[1].properties");

    assertThat(returnedFilterId).isEqualTo(MockProvider.ANOTHER_EXAMPLE_FILTER_ID);
    assertThat(returnedResourceType).isEqualTo(MockProvider.EXAMPLE_FILTER_RESOURCE_TYPE);
    assertThat(returnedName).isEqualTo(MockProvider.EXAMPLE_FILTER_NAME);
    assertThat(returnedOwner).isEqualTo(MockProvider.EXAMPLE_FILTER_OWNER);
    assertThat(returnedQuery.get("name")).isEqualTo(MockProvider.EXAMPLE_FILTER_QUERY_DTO.getName());
    assertThat(returnedProperties).isEqualTo(MockProvider.EXAMPLE_FILTER_PROPERTIES);
  }

  protected void verifyQueryMockMultipleParameters() {
    verify(mockedQuery).filterId(MockProvider.EXAMPLE_FILTER_ID);
    verify(mockedQuery).filterResourceType(MockProvider.EXAMPLE_FILTER_RESOURCE_TYPE);
    verify(mockedQuery).filterName(MockProvider.EXAMPLE_FILTER_NAME);
    verify(mockedQuery).filterNameLike(MockProvider.EXAMPLE_FILTER_NAME);
    verify(mockedQuery).filterOwner(MockProvider.EXAMPLE_FILTER_OWNER);
  }

  protected void executeAndVerifySorting(String sortBy, String sortOrder, Status expectedStatus) {
    Map<String, String> params = new HashMap<String, String>();
    params.put("sortBy", sortBy);
    params.put("sortOrder", sortOrder);

    given()
      .queryParams(params)
    .then().expect()
      .statusCode(expectedStatus.getStatusCode())
    .when()
      .get(FILTER_QUERY_URL);

    if (expectedStatus.equals(Status.OK)) {
      verifyQueryMockSorting(sortBy, sortOrder);
    }
  }

  protected void verifyQueryMockSorting(String sortBy, String sortOrder) {
    InOrder inOrder = inOrder(mockedQuery);
    if (sortBy.equals(FilterQueryDto.SORT_BY_ID_VALUE)) {
      inOrder.verify(mockedQuery).orderByFilterId();
    }
    else if (sortBy.equals(FilterQueryDto.SORT_BY_RESOURCE_TYPE_VALUE)) {
      inOrder.verify(mockedQuery).orderByFilterResourceType();
    }
    else if (sortBy.equals(FilterQueryDto.SORT_BY_NAME_VALUE)) {
      inOrder.verify(mockedQuery).orderByFilterName();
    }
    else if (sortBy.equals(FilterQueryDto.SORT_BY_OWNER_VALUE)) {
      inOrder.verify(mockedQuery).orderByFilterOwner();
    }

    if (sortOrder.equals(AbstractQuery.SORTORDER_ASC)) {
      inOrder.verify(mockedQuery).asc();
    }
    else if (sortOrder.equals(AbstractQuery.SORTORDER_DESC)) {
      inOrder.verify(mockedQuery).desc();
    }
  }

  protected void executeAndVerifyPagination(Integer firstResult, Integer maxResults, Status expectedStatus) {
    Map<String, String> params = new HashMap<String, String>();
    if (firstResult != null) {
      params.put("firstResult", firstResult.toString());
    }
    if (maxResults != null) {
      params.put("maxResults", maxResults.toString());
    }

    given()
      .queryParams(params)
    .then().expect()
      .statusCode(expectedStatus.getStatusCode())
    .when()
      .get(FILTER_QUERY_URL);

    verifyQueryMockPagination(firstResult, maxResults);

  }

  protected void verifyQueryMockPagination(Integer firstResult, Integer maxResults) {
    if (firstResult == null) {
      firstResult = 0;
    }
    if (maxResults == null) {
      maxResults = Integer.MAX_VALUE;
    }

    verify(mockedQuery).listPage(firstResult, maxResults);
  }

}


text:
package mcjty.enigma.code;

import mcjty.enigma.Enigma;
import mcjty.enigma.compat.LostCitySupport;
import mcjty.enigma.parser.Expression;
import mcjty.enigma.parser.ExpressionContext;
import mcjty.enigma.parser.ExpressionFunction;
import mcjty.enigma.parser.ObjectTools;
import mcjty.enigma.progress.MobConfig;
import mcjty.enigma.progress.PlayerProgress;
import mcjty.enigma.progress.Progress;
import mcjty.enigma.progress.ProgressHolder;
import mcjty.enigma.varia.*;
import mcjty.lib.tools.InventoryTools;
import mcjty.lib.tools.ItemStackTools;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.fml.common.registry.ForgeRegistries;

import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import static mcjty.enigma.varia.StringRegister.STRINGS;

public class EnigmaExpressionContext implements ExpressionContext<EnigmaFunctionContext> {

    private final Progress progress;

    public EnigmaExpressionContext(Progress progress) {
        this.progress = progress;
    }

    public static final Map<String, ExpressionFunction<EnigmaFunctionContext>> FUNCTIONS = new HashMap<>();

    private static Random random = new Random(System.currentTimeMillis());

    static {
        FUNCTIONS.put("fmt_black", (context, o) -> String.valueOf(TextFormatting.BLACK));
        FUNCTIONS.put("fmt_darkblue", (context, o) -> String.valueOf(TextFormatting.DARK_BLUE));
        FUNCTIONS.put("fmt_darkgreen", (context, o) -> String.valueOf(TextFormatting.DARK_GREEN));
        FUNCTIONS.put("fmt_darkaqua", (context, o) -> String.valueOf(TextFormatting.DARK_AQUA));
        FUNCTIONS.put("fmt_darkred", (context, o) -> String.valueOf(TextFormatting.DARK_RED));
        FUNCTIONS.put("fmt_darkpurple", (context, o) -> String.valueOf(TextFormatting.DARK_PURPLE));
        FUNCTIONS.put("fmt_gold", (context, o) -> String.valueOf(TextFormatting.GOLD));
        FUNCTIONS.put("fmt_gray", (context, o) -> String.valueOf(TextFormatting.GRAY));
        FUNCTIONS.put("fmt_darkgray", (context, o) -> String.valueOf(TextFormatting.DARK_GRAY));
        FUNCTIONS.put("fmt_blue", (context, o) -> String.valueOf(TextFormatting.BLUE));
        FUNCTIONS.put("fmt_green", (context, o) -> String.valueOf(TextFormatting.GREEN));
        FUNCTIONS.put("fmt_aqua", (context, o) -> String.valueOf(TextFormatting.AQUA));
        FUNCTIONS.put("fmt_red", (context, o) -> String.valueOf(TextFormatting.RED));
        FUNCTIONS.put("fmt_lightpurple", (context, o) -> String.valueOf(TextFormatting.LIGHT_PURPLE));
        FUNCTIONS.put("fmt_yellow", (context, o) -> String.valueOf(TextFormatting.YELLOW));
        FUNCTIONS.put("fmt_white", (context, o) -> String.valueOf(TextFormatting.WHITE));
        FUNCTIONS.put("fmt_bold", (context, o) -> String.valueOf(TextFormatting.BOLD));
        FUNCTIONS.put("fmt_strikethrough", (context, o) -> String.valueOf(TextFormatting.STRIKETHROUGH));
        FUNCTIONS.put("fmt_underline", (context, o) -> String.valueOf(TextFormatting.UNDERLINE));
        FUNCTIONS.put("fmt_italic", (context, o) -> String.valueOf(TextFormatting.ITALIC));
        FUNCTIONS.put("fmt_reset", (context, o) -> String.valueOf(TextFormatting.RESET));

        FUNCTIONS.put("lc_valid", (context, o) -> Enigma.lostcities && LostCitySupport.isLostCity(context.getWorld()));
        FUNCTIONS.put("lc_floor0", (context, o) -> {
            if (Enigma.lostcities) {
                Progress progress = ProgressHolder.getProgress(context.getWorld());
                BlockPosDim namedPosition = progress.getNamedPosition(o[0]);
                return LostCitySupport.getFloor0Height(context.getWorld(), namedPosition.getPos());
            } else {
                return -1;
            }
        });

        FUNCTIONS.put("pos", (context, o) -> {
            if (o.length == 1) {
                Progress progress = ProgressHolder.getProgress(context.getWorld());
                BlockPosDim namedPosition = progress.getNamedPosition(o[0]);
                if (namedPosition == null) {
                    MobConfig mobConfig = progress.getNamedMobConfig(o[0]);
                    if (mobConfig == null) {
                        throw new ExecutionException("Cannot find position or mob " + o[0] + "!");
                    }
                    String tag = "enigma:" + (o[0] instanceof String ? (String) o[0] : STRINGS.get((Integer) o[0]));
                    String t2 = ObjectTools.asStringSafe(o[0]);
                    List<Entity> entities = context.getWorld().getEntities(Entity.class, input -> (input.getTags().contains(tag) || input.getTags().contains(t2)));
                    for (Entity e : entities) {
                        return new BlockPosDim(e.getPosition(), e.dimension);
                    }
                }
                return namedPosition;
            } else if (o.length > 3) {
                return new BlockPosDim(new BlockPos(ObjectTools.asIntSafe(o[0]), ObjectTools.asIntSafe(o[1]), ObjectTools.asIntSafe(o[2])), ObjectTools.asIntSafe(o[3]));
            } else {
                int dim = 0;
                if (context.hasPlayer()) {
                    dim = context.getPlayer().getEntityWorld().provider.getDimension();
                }
                return new BlockPosDim(new BlockPos(ObjectTools.asIntSafe(o[0]), ObjectTools.asIntSafe(o[1]), ObjectTools.asIntSafe(o[2])), dim);
            }
        });
        FUNCTIONS.put("playerpos", (context, o) -> new BlockPosDim(context.getPlayer().getPosition(), context.getPlayer().getEntityWorld().provider.getDimension()));
        FUNCTIONS.put("getx", (context, o) -> {
            Progress progress = ProgressHolder.getProgress(context.getWorld());
            BlockPosDim namedPosition = progress.getNamedPosition(o[0]);
            if (namedPosition == null) {
                throw new ExecutionException("Cannot find position " + o[0] + "!");
            }
            return namedPosition.getPos().getX();
        });
        FUNCTIONS.put("gety", (context, o) -> {
            Progress progress = ProgressHolder.getProgress(context.getWorld());
            BlockPosDim namedPosition = progress.getNamedPosition(o[0]);
            if (namedPosition == null) {
                throw new ExecutionException("Cannot find position " + o[0] + "!");
            }
            return namedPosition.getPos().getY();
        });
        FUNCTIONS.put("getz", (context, o) -> {
            Progress progress = ProgressHolder.getProgress(context.getWorld());
            BlockPosDim namedPosition = progress.getNamedPosition(o[0]);
            if (namedPosition == null) {
                throw new ExecutionException("Cannot find position " + o[0] + "!");
            }
            return namedPosition.getPos().getZ();
        });
        FUNCTIONS.put("mincorner", (context, o) -> {
            Progress progress = ProgressHolder.getProgress(context.getWorld());
            Area namedArea = progress.getNamedArea(o[0]);
            if (namedArea == null) {
                throw new ExecutionException("Cannot find area " + o[0] + "!");
            }
            return new BlockPosDim(namedArea.getPos1(), namedArea.getDimension());
        });
        FUNCTIONS.put("maxcorner", (context, o) -> {
            Progress progress = ProgressHolder.getProgress(context.getWorld());
            Area namedArea = progress.getNamedArea(o[0]);
            if (namedArea == null) {
                throw new ExecutionException("Cannot find area " + o[0] + "!");
            }
            return new BlockPosDim(namedArea.getPos2(), namedArea.getDimension());
        });
        FUNCTIONS.put("getdim", (context, o) -> {
            IPositional positional = AreaTools.getPositional(ProgressHolder.getProgress(context.getWorld()), o[0]);
            return positional.getDimension();
        });
        FUNCTIONS.put("up", (context, o) -> {
            IPositional positional = AreaTools.getPositional(ProgressHolder.getProgress(context.getWorld()), o[0]);
            return positional.up(ObjectTools.asIntSafe(o[1]));
        });
        FUNCTIONS.put("down", (context, o) -> {
            IPositional positional = AreaTools.getPositional(ProgressHolder.getProgress(context.getWorld()), o[0]);
            return positional.down(ObjectTools.asIntSafe(o[1]));
        });
        FUNCTIONS.put("south", (context, o) -> {
            IPositional positional = AreaTools.getPositional(ProgressHolder.getProgress(context.getWorld()), o[0]);
            return positional.south(ObjectTools.asIntSafe(o[1]));
        });
        FUNCTIONS.put("north", (context, o) -> {
            IPositional positional = AreaTools.getPositional(ProgressHolder.getProgress(context.getWorld()), o[0]);
            return positional.north(ObjectTools.asIntSafe(o[1]));
        });
        FUNCTIONS.put("west", (context, o) -> {
            IPositional positional = AreaTools.getPositional(ProgressHolder.getProgress(context.getWorld()), o[0]);
            return positional.west(ObjectTools.asIntSafe(o[1]));
        });
        FUNCTIONS.put("east", (context, o) -> {
            IPositional positional = AreaTools.getPositional(ProgressHolder.getProgress(context.getWorld()), o[0]);
            return positional.east(ObjectTools.asIntSafe(o[1]));
        });
        FUNCTIONS.put("lookat", (context, o) -> {
            double maxdist = ObjectTools.asDoubleSafe(o[0]);
            EntityPlayer player = context.getPlayer();
            if (player == null) {
                throw new ExecutionException("Player is needed for 'lookat' function!");
            }
            World world = player.getEntityWorld();
            int dimension = world.provider.getDimension();
            Vec3d offset = player.getLookVec().normalize().scale(maxdist);
            Vec3d pp = new Vec3d(player.posX, player.posY, player.posZ);
            RayTraceResult result = world.rayTraceBlocks(pp, pp.add(offset));
            if (result == null) {
                return null;
            }
            return new BlockPosDim(result.getBlockPos(), dimension);
        });
        FUNCTIONS.put("posat", (context, o) -> {
            double dist = ObjectTools.asDoubleSafe(o[0]);
            EntityPlayer player = context.getPlayer();
            if (player == null) {
                throw new ExecutionException("Player is needed for 'posat' function!");
            }
            Vec3d offset = player.getLookVec().normalize().scale(dist);
            return new BlockPosDim(player.getPosition().add(offset.xCoord, offset.yCoord, offset.zCoord), player.getEntityWorld().provider.getDimension());
        });
        FUNCTIONS.put("yaw", (context, o) -> {
            EntityPlayer player = context.getPlayer();
            if (player == null) {
                throw new ExecutionException("Player is needed for 'yaw' function!");
            }
            if (o.length == 0) {
                return (double) player.rotationYaw;
            } else {
                Progress progress = ProgressHolder.getProgress(context.getWorld());
                BlockPosDim namedPosition = progress.getNamedPosition(o[0]);
                if (namedPosition == null) {
                    throw new ExecutionException("Cannot find position " + o[0] + "!");
                }
                BlockPos p = namedPosition.getPos();
                double d0 = p.getX() + .5 - player.posX;
                double d1 = p.getY() + .5 - player.posY - player.getEyeHeight();
                double d2 = p.getZ() + .5 - player.posZ;

                double d3 = Math.sqrt(d0 * d0 + d2 * d2);
                return (Math.atan2(d2, d0) * (180D / Math.PI)) - 90.0F;
            }
        });
        FUNCTIONS.put("pitch", (context, o) -> {
            EntityPlayer player = context.getPlayer();
            if (player == null) {
                throw new ExecutionException("Player is needed for 'pitch' function!");
            }
            if (o.length == 0) {
                return (double) player.rotationPitch;
            } else {
                Progress progress = ProgressHolder.getProgress(context.getWorld());
                BlockPosDim namedPosition = progress.getNamedPosition(o[0]);
                if (namedPosition == null) {
                    throw new ExecutionException("Cannot find position " + o[0] + "!");
                }
                BlockPos p = namedPosition.getPos();
                double d0 = p.getX() + .5 - player.posX;
                double d1 = p.getY() + .5 - player.posY - player.getEyeHeight();
                double d2 = p.getZ() + .5 - player.posZ;

                double d3 = Math.sqrt(d0 * d0 + d2 * d2);
                return (-(Math.atan2(d1, d3) * (180D / Math.PI)));
            }
        });

        FUNCTIONS.put("istr", (context, o) -> {
            if (o[0] instanceof Integer) {
                return STRINGS.get((Integer) o[0]);
            } else {
                return ObjectTools.asStringSafe(o[0]);
            }
        });
        FUNCTIONS.put("intern", (context, o) -> {
            if (o[0] instanceof String) {
                return STRINGS.get((String) o[0]);
            } else {
                return o[0];
            }
        });
        FUNCTIONS.put("max", (context, o) -> {
            if (o[0] instanceof Integer) {
                int m = ObjectTools.asIntSafe(o[0]);
                for (int i = 1 ; i < o.length ; i++) {
                    m = Math.max(m, ObjectTools.asIntSafe(o[i]));
                }
                return m;
            } else if (o[0] instanceof Double) {
                double m = ObjectTools.asDoubleSafe(o[0]);
                for (int i = 1 ; i < o.length ; i++) {
                    m = Math.max(m, ObjectTools.asDoubleSafe(o[i]));
                }
                return m;
            } else if (o[0] instanceof String) {
                String m = ObjectTools.asStringSafe(o[0]);
                for (int i = 1 ; i < o.length ; i++) {
                    String s = ObjectTools.asStringSafe(o[1]);
                    m = m.compareTo(s) < 0 ? s : m;
                }
                return m;
            } else if (o[0] instanceof Boolean) {
                boolean m = ObjectTools.asBoolSafe(o[0]);
                for (int i = 1 ; i < o.length ; i++) {
                    m = m || ObjectTools.asBoolSafe(o[i]);
                }
                return m;
            } else {
                return o[0];
            }
        });
        FUNCTIONS.put("min", (context, o) -> {
            if (o[0] instanceof Integer) {
                int m = ObjectTools.asIntSafe(o[0]);
                for (int i = 1 ; i < o.length ; i++) {
                    m = Math.min(m, ObjectTools.asIntSafe(o[i]));
                }
                return m;
            } else if (o[0] instanceof Double) {
                double m = ObjectTools.asDoubleSafe(o[0]);
                for (int i = 1 ; i < o.length ; i++) {
                    m = Math.min(m, ObjectTools.asDoubleSafe(o[i]));
                }
                return m;
            } else if (o[0] instanceof String) {
                String m = ObjectTools.asStringSafe(o[0]);
                for (int i = 1 ; i < o.length ; i++) {
                    String s = ObjectTools.asStringSafe(o[1]);
                    m = m.compareTo(s) < 0 ? m : s;
                }
                return m;
            } else if (o[0] instanceof Boolean) {
                boolean m = ObjectTools.asBoolSafe(o[0]);
                for (int i = 1 ; i < o.length ; i++) {
                    m = m && ObjectTools.asBoolSafe(o[i]);
                }
                return m;
            } else {
                return o[0];
            }
        });
        FUNCTIONS.put("str", (context, o) -> ObjectTools.asStringSafe(o[0]));
        FUNCTIONS.put("int", (context, o) -> ObjectTools.asIntSafe(o[0]));
        FUNCTIONS.put("double", (context, o) -> ObjectTools.asDoubleSafe(o[0]));
        FUNCTIONS.put("boolean", (context, o) -> ObjectTools.asBoolSafe(o[0]));

        FUNCTIONS.put("random", (context, o) -> random.nextDouble());

        FUNCTIONS.put("state", (context, o) -> {
            Progress progress = ProgressHolder.getProgress(context.getWorld());
            return progress.getState(o[0]);
        });
        FUNCTIONS.put("pstate", (context, o) -> {
            Progress progress = ProgressHolder.getProgress(context.getWorld());
            PlayerProgress playerProgress = progress.getPlayerProgress(context.getPlayer().getPersistentID());
            return playerProgress.getState(o[0]);
        });
        FUNCTIONS.put("blockname", (context, o) -> {
            Progress progress = ProgressHolder.getProgress(context.getWorld());
            BlockPosDim namedPosition = progress.getNamedPosition(o[0]);
            if (namedPosition == null) {
                throw new ExecutionException("Cannot find position " + o[0] + "!");
            }
            IBlockState state = DimensionManager.getWorld(namedPosition.getDimension()).getBlockState(namedPosition.getPos());
            if (state == null) {
                return "";  // Not a named block
            }
            return STRINGS.get(progress.getNamedBlock(state));
        });
        FUNCTIONS.put("substring", (context, o) -> {
            String s = ObjectTools.asStringSafe(o[0]);
            int idx1 = ObjectTools.asIntSafe(o[1]);
            if (o.length > 2) {
                int idx2 = ObjectTools.asIntSafe(o[2]);
                return s.substring(idx1, idx2);
            } else {
                return s.substring(idx1);
            }
        });
        FUNCTIONS.put("isblock", (context, o) -> {
            Progress progress = ProgressHolder.getProgress(context.getWorld());
            BlockPosDim namedPosition = progress.getNamedPosition(o[0]);
            if (namedPosition == null) {
                throw new ExecutionException("Cannot find position " + o[0] + "!");
            }
            IBlockState state = progress.getNamedBlock(o[1]);
            if (state == null) {
                throw new ExecutionException("Cannot find block state " + o[1] + "!");
            }
            return DimensionManager.getWorld(namedPosition.getDimension()).getBlockState(namedPosition.getPos()).equals(state);
        });
        FUNCTIONS.put("itemstack", (context, o) -> {
            if (o[0] instanceof String) {
                int amount = 1;
                int meta = 0;
                if (o.length > 1) {
                    amount = ObjectTools.asIntSafe(o[1]);
                    if (o.length > 2) {
                        meta = ObjectTools.asIntSafe(o[2]);
                    }
                }
                String n = ObjectTools.asStringSafe(o[0]);
                Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(n));
                if (item != null) {
                    return new ItemStack(item, amount, meta);
                }
                Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(n));
                if (block != null) {
                    return new ItemStack(block, amount, meta);
                }
                throw new ExecutionException("Cannot find item or block '" + n + "'!");
            } else {
                Progress progress = ProgressHolder.getProgress(context.getWorld());
                return progress.getNamedItemStack(o[0]);
            }
        });
        FUNCTIONS.put("hasitem", (context, o) -> {
            Progress progress = ProgressHolder.getProgress(context.getWorld());
            ItemStack stack = progress.getNamedItemStack(o[0]);
            if (ItemStackTools.isValid(stack)) {
                List<ItemStack> items = InventoryTools.getMainInventory(context.getPlayer());
                for (ItemStack item : items) {
                    if (ItemStackTools.isValid(item)) {
                        if (InventoryHelper.stackEqualExact(item, stack)) {
                            return true;
                        }
                    }
                }
            } else {
                throw new ExecutionException("Cannot find item " + o[0] + "!");
            }
            return false;
        });
        FUNCTIONS.put("hasitemmain", (context, o) -> {
            Progress progress = ProgressHolder.getProgress(context.getWorld());
            ItemStack stack = progress.getNamedItemStack(o[0]);
            if (ItemStackTools.isValid(stack)) {
                if (InventoryHelper.stackEqualExact(stack, context.getPlayer().getHeldItem(EnumHand.MAIN_HAND))) {
                    return true;
                }
            } else {
                throw new ExecutionException("Cannot find item " + o[0] + "!");
            }
            return false;
        });
        FUNCTIONS.put("hasitemoff", (context, o) -> {
            Progress progress = ProgressHolder.getProgress(context.getWorld());
            ItemStack stack = progress.getNamedItemStack(o[0]);
            if (ItemStackTools.isValid(stack)) {
                if (InventoryHelper.stackEqualExact(stack, context.getPlayer().getHeldItem(EnumHand.OFF_HAND))) {
                    return true;
                }
            } else {
                throw new ExecutionException("Cannot find item " + o[0] + "!");
            }
            return false;
        });
        FUNCTIONS.put("distance", (context, o) -> {
            Progress progress = ProgressHolder.getProgress(context.getWorld());
            BlockPosDim pos1 = progress.getNamedPosition(o[0]);
            if (pos1 == null) {
                throw new ExecutionException("Cannot find position " + o[0] + "!");
            }
            BlockPos pos2;
            if (o.length > 1) {
                BlockPosDim p2 = progress.getNamedPosition(o[1]);
                if (p2 == null) {
                    throw new ExecutionException("Cannot find position " + o[1] + "!");
                }
                if (pos1.getDimension() != p2.getDimension()) {
                    return -1;
                }
                pos2 = p2.getPos();
            } else {
                EntityPlayer player = context.getPlayer();
                if (player.getEntityWorld().provider.getDimension() != pos1.getDimension()) {
                    return -1;
                }
                pos2 = player.getPosition();
            }
            return BlockPosDim.distance(pos1.getPos(), pos2);
        });

    }

    @Nullable
    @Override
    public Expression<EnigmaFunctionContext> getVariable(String var) {
        int i = STRINGS.get(var);
        return context -> {
            if (context.isLocalVar(i)) {
                return context.getLocalVar(i);
            } else if (context.hasPlayer() && progress.getPlayerProgress(context.getPlayer().getPersistentID()).isNamedVariable(i)) {
                return progress.getPlayerProgress(context.getPlayer().getPersistentID()).getNamedVariable(i);
            } else if (progress.isNamedVariable(i)) {
                return progress.getNamedVariable(i);
            } else {
                return var;
            }
        };
    }

    @Nullable
    @Override
    public ExpressionFunction<EnigmaFunctionContext> getFunction(String name) {
        return FUNCTIONS.get(name);
    }

    @Override
    public boolean isFunction(String name) {
        return FUNCTIONS.containsKey(name);
    }
}


text:
{{{
  "title": "June 2014 Bandwidth Model Change FAQ",
  "date": "9-2-2014",
  "author": "Richard Seroter",
  "attachments": [],
  "contentIsHTML": true
}}}

CenturyLink Cloud recently announced a change to the bandwidth billing model and a corresponding price drop. The questions and answers below describe the change and its impact.

Q: What change are you making?

A: CenturyLink Cloud is changing from a 95th percentile bandwidth billing model to a model based on price per GB of data transferred. Instead of paying $22 per Mbps, you will now pay $0.05 per GB of outbound data transferred.

Q: When does this take effect?

A: This pricing change will take effect on your July 1, 2014 invoice.

Q: Do I have to do anything to activate this price drop?

A: No! All customers will see this price drop automatically.

Q: Why did you make this change?

A: Multiple reasons. First, as part of telecommunications company CenturyLink, we can offer the most competitive bandwidth rates in the cloud industry. Second, we wanted to simplify bandwidth billing and make it easier for customers to
  understand their consumption.

Q: What's the impact on the price that I was paying before?

A: In the previous 95th percentile billing model, you paid for average consumption of inbound and outbound bandwidth over the course of the month (minus the peak 5% of usage). If you consumed 3 Mbps over the course of the month (1 Mbps
  inbound, and 2 Mbps outbound), that would cost you $66 dollars. Now, we are only charging for outbound bandwidth -- and given that 1Mbps equals about 320GB of data transferred --
  so the same usage would cost just $16 ($0.05 * 320). In nearly every case, this is a noticeable price difference for CenturyLink Cloud customers.

Q: How does this differ from how other cloud providers bill for bandwidth?

A: Nearly all providers bill based on bandwidth transferred, but unlike those providers, CenturyLink Cloud has a single low rate that applies to any amount of bandwidth transferred. Most providers use a graduated rate that starts at more
  than $0.12 per GB and eventually reaches $0.05 after you transfer hundreds of terabytes of data.

Q: What network consumption do I *not* pay for?

A: You are not charged for any data transferred within our data centers (between virtual machines) or inbound bandwidth into your cloud environment.

Q: What changes will I see in the CenturyLink Cloud Control Portal?

A: The bandwidth graph on the dashboard page will now show your last 7 days of billable data transfer across all data centers. In addition, because we are constantly calculating bandwidth consumption (versus final aggregation at invoice
  time with the 95th percentage model), bandwidth charges are included in the current hour / month to date charges shown across the Control Portal.

Q: Will my invoice look different now?

A: Slightly. The invoice will now show:

Description

Quantity

Unit Cost

Total

Bandwidth: GB Transmitted (<data center>)

100

$0.05

$5.00


text:
Release Process
====================

* update translations (ping wumpus, Diapolo or tcatm on IRC)
* see https://github.com/bitcoin/bitcoin/blob/master/doc/translation_process.md#syncing-with-transifex

* * *

###update (commit) version in sources

	bitcoin-qt.pro
	contrib/verifysfbinaries/verify.sh
	doc/README*
	share/setup.nsi
	src/clientversion.h (change CLIENT_VERSION_IS_RELEASE to true)

###tag version in git

	git tag -s v(new version, e.g. 0.8.0)

###write release notes. git shortlog helps a lot, for example:

	git shortlog --no-merges v(current version, e.g. 0.7.2)..v(new version, e.g. 0.8.0)

* * *

##perform gitian builds

 From a directory containing the horuscoin source, gitian-builder and gitian.sigs

	export SIGNER=(your gitian key, ie bluematt, sipa, etc)
	export VERSION=(new version, e.g. 0.8.0)
	pushd ./horuscoin
	git checkout v${VERSION}
	popd
	pushd ./gitian-builder

 Fetch and build inputs: (first time, or when dependency versions change)

	mkdir -p inputs; cd inputs/
	wget 'http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.8.tar.gz' -O miniupnpc-1.8.tar.gz
	wget 'https://www.openssl.org/source/openssl-1.0.1g.tar.gz'
	wget 'http://download.oracle.com/berkeley-db/db-5.1.29.NC.tar.gz'
	wget 'http://zlib.net/zlib-1.2.8.tar.gz'
	wget 'ftp://ftp.simplesystems.org/pub/png/src/history/libpng16/libpng-1.6.8.tar.gz'
	wget 'https://fukuchi.org/works/qrencode/qrencode-3.4.3.tar.bz2'
	wget 'https://downloads.sourceforge.net/project/boost/boost/1.55.0/boost_1_55_0.tar.bz2'
	wget 'https://svn.boost.org/trac/boost/raw-attachment/ticket/7262/boost-mingw.patch' -O \
	     boost-mingw-gas-cross-compile-2013-03-03.patch
	wget 'https://download.qt-project.org/official_releases/qt/5.2/5.2.0/single/qt-everywhere-opensource-src-5.2.0.tar.gz'
	wget 'https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.bz2'
	cd ..
	./bin/gbuild ../horuscoin/contrib/gitian-descriptors/boost-linux.yml
	mv build/out/boost-*.zip inputs/
	./bin/gbuild ../horuscoin/contrib/gitian-descriptors/deps-linux.yml
	mv build/out/horuscoin-deps-*.zip inputs/
	./bin/gbuild ../horuscoin/contrib/gitian-descriptors/boost-win.yml
	mv build/out/boost-*.zip inputs/
	./bin/gbuild ../horuscoin/contrib/gitian-descriptors/deps-win.yml
	mv build/out/horuscoin-deps-*.zip inputs/
	./bin/gbuild ../horuscoin/contrib/gitian-descriptors/qt-win.yml
	mv build/out/qt-*.zip inputs/
	./bin/gbuild ../horuscoin/contrib/gitian-descriptors/protobuf-win.yml
	mv build/out/protobuf-*.zip inputs/

 Build horuscoind and horuscoin-qt on Linux32, Linux64, and Win32:

	./bin/gbuild --commit bitcoin=v${VERSION} ../horuscoin/contrib/gitian-descriptors/gitian-linux.yml
	./bin/gsign --signer $SIGNER --release ${VERSION} --destination ../gitian.sigs/ ../horuscoin/contrib/gitian-descriptors/gitian-linux.yml
	pushd build/out
	zip -r horuscoin-${VERSION}-linux-gitian.zip *
	mv horuscoin-${VERSION}-linux-gitian.zip ../../../
	popd
	./bin/gbuild --commit bitcoin=v${VERSION} ../horuscoin/contrib/gitian-descriptors/gitian-win.yml
	./bin/gsign --signer $SIGNER --release ${VERSION}-win --destination ../gitian.sigs/ ../horuscoin/contrib/gitian-descriptors/gitian-win.yml
	pushd build/out
	zip -r horuscoin-${VERSION}-win-gitian.zip *
	mv horuscoin-${VERSION}-win-gitian.zip ../../../
	popd
	popd

  Build output expected:

  1. linux 32-bit and 64-bit binaries + source (horuscoin-${VERSION}-linux-gitian.zip)
  2. windows 32-bit and 64-bit binaries + installer + source (horuscoin-${VERSION}-win-gitian.zip)
  3. Gitian signatures (in gitian.sigs/${VERSION}[-win]/(your gitian key)/

repackage gitian builds for release as stand-alone zip/tar/installer exe

**Linux .tar.gz:**

	unzip horuscoin-${VERSION}-linux-gitian.zip -d horuscoin-${VERSION}-linux
	tar czvf horuscoin-${VERSION}-linux.tar.gz horuscoin-${VERSION}-linux
	rm -rf horuscoin-${VERSION}-linux

**Windows .zip and setup.exe:**

	unzip horuscoin-${VERSION}-win-gitian.zip -d horuscoin-${VERSION}-win
	mv horuscoin-${VERSION}-win/horuscoin-*-setup.exe .
	zip -r horuscoin-${VERSION}-win.zip horuscoin-${VERSION}-win
	rm -rf horuscoin-${VERSION}-win

**Perform Mac build:**

  OSX binaries are created by Gavin Andresen on a 64-bit, OSX 10.6 machine.

	./autogen.sh
        SDK=$(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk
        CXXFLAGS="-mmacosx-version-min=10.6 -isysroot $SDK" ./configure --enable-upnp-default
	make
	export QTDIR=/opt/local/share/qt4  # needed to find translations/qt_*.qm files
	T=$(contrib/qt_translations.py $QTDIR/translations src/qt/locale)
        export CODESIGNARGS='--keychain ...path_to_keychain --sign "Developer ID Application: HORUSCOIN FOUNDATION, INC., THE"'
	python2.7 contrib/macdeploy/macdeployqtplus Horuscoin-Qt.app -sign -add-qt-tr $T -dmg -fancy contrib/macdeploy/fancy.plist

 Build output expected: Horuscoin-Qt.dmg

###Next steps:

* Code-sign Windows -setup.exe (in a Windows virtual machine using signtool)
 Note: only Gavin has the code-signing keys currently.

* upload builds to SourceForge

* create SHA256SUMS for builds, and PGP-sign it

* update horuscoin.info version
  make sure all OS download links go to the right versions

* update forum version

* update wiki download links

* update wiki changelog: [https://en.bitcoin.it/wiki/Changelog](https://en.bitcoin.it/wiki/Changelog)

Commit your signature to gitian.sigs:

	pushd gitian.sigs
	git add ${VERSION}/${SIGNER}
	git add ${VERSION}-win/${SIGNER}
	git commit -a
	git push  # Assuming you can push to the gitian.sigs tree
	popd

-------------------------------------------------------------------------

### After 3 or more people have gitian-built, repackage gitian-signed zips:

From a directory containing bitcoin source, gitian.sigs and gitian zips

	export VERSION=(new version, e.g. 0.8.0)
	mkdir bitcoin-${VERSION}-linux-gitian
	pushd bitcoin-${VERSION}-linux-gitian
	unzip ../horuscoin-${VERSION}-linux-gitian.zip
	mkdir gitian
	cp ../horuscoin/contrib/gitian-downloader/*.pgp ./gitian/
	for signer in $(ls ../gitian.sigs/${VERSION}/); do
	 cp ../gitian.sigs/${VERSION}/${signer}/horuscoin-build.assert ./gitian/${signer}-build.assert
	 cp ../gitian.sigs/${VERSION}/${signer}/horuscoin-build.assert.sig ./gitian/${signer}-build.assert.sig
	done
	zip -r bitcoin-${VERSION}-linux-gitian.zip *
	cp bitcoin-${VERSION}-linux-gitian.zip ../
	popd
	mkdir bitcoin-${VERSION}-win-gitian
	pushd bitcoin-${VERSION}-win-gitian
	unzip ../horuscoin-${VERSION}-win-gitian.zip
	mkdir gitian
	cp ../horuscoin/contrib/gitian-downloader/*.pgp ./gitian/
	for signer in $(ls ../gitian.sigs/${VERSION}-win/); do
	 cp ../gitian.sigs/${VERSION}-win/${signer}/horuscoin-build.assert ./gitian/${signer}-build.assert
	 cp ../gitian.sigs/${VERSION}-win/${signer}/horuscoin-build.assert.sig ./gitian/${signer}-build.assert.sig
	done
	zip -r bitcoin-${VERSION}-win-gitian.zip *
	cp bitcoin-${VERSION}-win-gitian.zip ../
	popd

- Upload gitian zips to SourceForge

- Announce the release:

  - Add the release to horuscoin.info

  - Announce on reddit /r/horuscoin, /r/horuscoindev

  - Release sticky on bitcointalk: https://bitcointalk.org/index.php?board=67.0

- Celebrate


text:
package org.jclouds.atmos.domain;

import java.net.URI;

import org.jclouds.atmos.domain.internal.DelegatingMutableContentMetadata;

import com.google.inject.ImplementedBy;

/**
 * metadata of the object
 */
@ImplementedBy(DelegatingMutableContentMetadata.class)
public interface MutableContentMetadata extends org.jclouds.io.MutableContentMetadata {

   String getName();

   void setName(String name);

   URI getUri();

   void setUri(URI uri);

   String getPath();

   void setPath(String path);
}


text:
//
//  INTUSpringSolver.c
//  https://github.com/intuit/AnimationEngine
//
//  Copyright (c) 2014 Facebook, Inc. All rights reserved.
//  Copyright (c) 2015 Intuit Inc.
//
//  Redistribution and use in source and binary forms, with or without modification,
//  are permitted provided that the following conditions are met:
//
//   * Redistributions of source code must retain the above copyright notice, this
//     list of conditions and the following disclaimer.
//
//   * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//
//   * Neither the name Facebook nor the names of its contributors may be used to
//     endorse or promote products derived from this software without specific
//     prior written permission.
//
//  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
//  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
//  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
//  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
//  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
//  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
//  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
//  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
//  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
//  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//

#include "INTUSpringSolver.h"
#include "INTUVector.h"
#include <stdlib.h>

/** The time step that the solver uses, in seconds. */
const double kINTUSolverDt = 0.001;

/** The factor that is multiplied with the norm of the initial position to determine a threshold value. */
const double kINTUThresholdFactor = 0.0001; // 0.01%

struct INTUSpringSolverContext {
    /** The stiffness of the spring. Must be greater than zero. */
    double stiffness;
    /** The amount of friction. Must be greater than or equal to zero. If exactly zero, the harmonic motion will continue forever and the solver will never converge.  */
    double damping;
    /** The amount of mass being moved by the spring. Must be greater than zero. */
    double mass;

    /** The threshold used to determine when the position is sufficiently close to the quiescent state. */
    double thresholdPosition;
    /** The threshold used to determine when the velocity is sufficiently close to the quiescent state. */
    double thresholdVelocity;
    /** The threshold used to determine when the acceleration is sufficiently close to the quiescent state. */
    double thresholdAcceleration;

    /** The time when the spring solver was last advanced. */
    double lastTime;
    /** The accumulated time that remains over which the spring's state needs to be calculated. */
    double accumulatedTime;

    /** The current position of the mass on the spring. */
    double currentPosition[kINTUSpringSolverDimensions];
    /** The current velocity of the mass on the spring. */
    double currentVelocity[kINTUSpringSolverDimensions];
    /** The current acceleration of the mass on the spring. */
    double currentAcceleration[kINTUSpringSolverDimensions];

    /** Whether the system that this context represents has been advanced yet. */
    bool started;
};
/** A private struct that stores the internal state of the spring solver. */
typedef struct INTUSpringSolverContext INTUSpringSolverContext;

static void resetContext(INTUSpringSolverContextRef context);

static void setConstants(INTUSpringSolverContextRef context, double k, double b, double m);

static void setThreshold(INTUSpringSolverContextRef context, double t);

static void integrate(INTUSpringSolverContextRef context,
                      const double *positionVector,
                      const double *velocityVector,
                      double t,
                      double dt,
                      double *outputPositionVector,
                      double *outputVelocityVector);

static void derivative(int dimension,
                       double *ax,
                       double *bx,
                       double *cx,
                       double *dx,
                       double *output);

static void evaluate(INTUSpringSolverContextRef context,
                     const double *positionVector,
                     const double *velocityVector,
                     double t,
                     double *deltaPosition,
                     double *deltaVelocity);

static void evaluateWithDerivative(INTUSpringSolverContextRef context,
                                   const double *positionVector,
                                   const double *velocityVector,
                                   double t,
                                   double dt,
                                   const double *inputDeltaPosition,
                                   const double *inputDeltaVelocity,
                                   double *outputDeltaPosition,
                                   double *outputDeltaVelocity);

static void acceleration(const INTUSpringSolverContextRef context,
                         const double *positionVector,
                         const double *velocityVector,
                         double t,
                         double *accelerationVector);

static void interpolate(int dimension,
                        const double *previousPositionVector,
                        const double *previousVelocityVector,
                        const double *currentPositionVector,
                        const double *currentVelocityVector,
                        double alpha,
                        double *outputPositionVector,
                        double *outputVelocityVector);

#pragma mark Public API

INTUSpringSolverContextRef INTUSpringSolverContextCreate(double stiffness,
                                                         double damping,
                                                         double mass,
                                                         const double *initialPosition,
                                                         const double *initialVelocity)
{
    if (stiffness <= 0.0 ||
        damping < 0.0 ||
        mass <= 0.0 ||
        initialPosition == NULL ||
        initialVelocity == NULL) {
        return NULL;
    }

    INTUSpringSolverContextRef context = malloc(sizeof(INTUSpringSolverContext));

    resetContext(context);

    setConstants(context, stiffness, damping, mass);

    // Take the norm of the initial position and multiply it by the threshold factor to get the threshold value.
    // This makes the threshold relative to the scale of whatever unit is being used in the starting position.
    double threshold = norm(kINTUSpringSolverDimensions, initialPosition) * kINTUThresholdFactor;
    setThreshold(context, threshold);

    copyVector(kINTUSpringSolverDimensions, initialPosition, context->currentPosition);
    copyVector(kINTUSpringSolverDimensions, initialVelocity, context->currentVelocity);

    return context;
}

void INTUSpringSolverContextDestroy(INTUSpringSolverContextRef context)
{
    free(context);
}

INTUSpringState INTUAdvanceSpringSolver(INTUSpringSolverContextRef context, double newTime)
{
    context->started = true;

    if (newTime < context->lastTime) {
        // The spring solver must always be advanced; sending in a newTime earlier than the last time is invalid.
        resetContext(context);
        INTUSpringState zeroState = {0};
        return zeroState;
    }

    context->accumulatedTime += (newTime - context->lastTime);
    double t = context->lastTime;
    context->lastTime = newTime;

    double currentPosition[kINTUSpringSolverDimensions], currentVelocity[kINTUSpringSolverDimensions];
    double previousPosition[kINTUSpringSolverDimensions], previousVelocity[kINTUSpringSolverDimensions];

    copyVector(kINTUSpringSolverDimensions, context->currentPosition, currentPosition);
    copyVector(kINTUSpringSolverDimensions, context->currentVelocity, currentVelocity);
    copyVector(kINTUSpringSolverDimensions, currentPosition, previousPosition);
    copyVector(kINTUSpringSolverDimensions, currentVelocity, previousVelocity);

    while (context->accumulatedTime >= kINTUSolverDt) {
        copyVector(kINTUSpringSolverDimensions, currentPosition, previousPosition);
        copyVector(kINTUSpringSolverDimensions, currentVelocity, previousVelocity);

        integrate(context, previousPosition, previousVelocity, t, kINTUSolverDt, currentPosition, currentVelocity);

        t += kINTUSolverDt;
        context->accumulatedTime -= kINTUSolverDt;
    }

    double alpha = context->accumulatedTime / kINTUSolverDt;
    double advancedPosition[kINTUSpringSolverDimensions], advancedVelocity[kINTUSpringSolverDimensions];

    interpolate(kINTUSpringSolverDimensions, previousPosition, previousVelocity, currentPosition, currentVelocity, alpha, advancedPosition, advancedVelocity);
    copyVector(kINTUSpringSolverDimensions, advancedPosition, context->currentPosition);
    copyVector(kINTUSpringSolverDimensions, advancedVelocity, context->currentVelocity);

    INTUSpringState newState;
    copyVector(kINTUSpringSolverDimensions, context->currentPosition, newState.position);
    return newState;
}

bool INTUSpringSolverHasConverged(INTUSpringSolverContextRef context)
{
    if (!context->started) {
        return false;
    }

    // Look at each dimension of the position vector, if any is significantly far away from zero, we have not converged.
    // In order for the spring solver to converge, the position vector must be approaching zero (with a tolerance of the threshold value).
    for (int i = 0; i < kINTUSpringSolverDimensions; i++) {
        if (fabs(context->currentPosition[i]) >= context->thresholdPosition) {
            return false;
        }
    }

    bool velocityConverged = (squaredNorm(kINTUSpringSolverDimensions, context->currentVelocity) < context->thresholdVelocity);

    bool accelerationConverged = (squaredNorm(kINTUSpringSolverDimensions, context->currentAcceleration) < context->thresholdAcceleration);

    return velocityConverged && accelerationConverged;
}

#pragma mark Internal Functions

static void resetContext(INTUSpringSolverContextRef context)
{
    context->lastTime = 0.0;
    context->accumulatedTime = 0.0;
    zeroVector(kINTUSpringSolverDimensions, context->currentPosition);
    zeroVector(kINTUSpringSolverDimensions, context->currentVelocity);
    zeroVector(kINTUSpringSolverDimensions, context->currentAcceleration);
    context->started = false;
}

static void setConstants(INTUSpringSolverContextRef context, double k, double b, double m)
{
    context->stiffness = k;
    context->damping = b;
    context->mass = m;
}

static void setThreshold(INTUSpringSolverContextRef context, double threshold)
{
    context->thresholdPosition = threshold / 2; // half a unit
    context->thresholdVelocity = 25.0 * threshold; // 5 units per second, squared for comparison
    context->thresholdAcceleration = 625.0 * threshold * threshold; // 5 units per second squared, squared for comparison
}

static void integrate(INTUSpringSolverContextRef context,
                      const double *positionVector,
                      const double *velocityVector,
                      double t,
                      double dt,
                      double *outputPositionVector,
                      double *outputVelocityVector)
{
    double derivativePositionA[kINTUSpringSolverDimensions], derivativeVelocityA[kINTUSpringSolverDimensions];
    double derivativePositionB[kINTUSpringSolverDimensions], derivativeVelocityB[kINTUSpringSolverDimensions];
    double derivativePositionC[kINTUSpringSolverDimensions], derivativeVelocityC[kINTUSpringSolverDimensions];
    double derivativePositionD[kINTUSpringSolverDimensions], derivativeVelocityD[kINTUSpringSolverDimensions];
    double dpdt[kINTUSpringSolverDimensions], dvdt[kINTUSpringSolverDimensions];
    double dpdtTimesDt[kINTUSpringSolverDimensions], dvdtTimesDt[kINTUSpringSolverDimensions];

    evaluate(context, positionVector, velocityVector, t, derivativePositionA, derivativeVelocityA);

    evaluateWithDerivative(context, positionVector, velocityVector, t, dt*0.5, derivativePositionA, derivativeVelocityA, derivativePositionB, derivativeVelocityB);
    evaluateWithDerivative(context, positionVector, velocityVector, t, dt*0.5, derivativePositionB, derivativeVelocityB, derivativePositionC, derivativeVelocityC);
    evaluateWithDerivative(context, positionVector, velocityVector, t, dt, derivativePositionC, derivativeVelocityC, derivativePositionD, derivativeVelocityD);

    derivative(kINTUSpringSolverDimensions, derivativePositionA, derivativePositionB, derivativePositionC, derivativePositionD, dpdt);
    derivative(kINTUSpringSolverDimensions, derivativeVelocityA, derivativeVelocityB, derivativeVelocityC, derivativeVelocityD, dvdt);

    multiplyScalarWithVector(kINTUSpringSolverDimensions, dt, dpdt, dpdtTimesDt);
    multiplyScalarWithVector(kINTUSpringSolverDimensions, dt, dvdt, dvdtTimesDt);

    addVectors(kINTUSpringSolverDimensions, positionVector, dpdtTimesDt, outputPositionVector);
    addVectors(kINTUSpringSolverDimensions, velocityVector, dvdtTimesDt, outputVelocityVector);

    copyVector(kINTUSpringSolverDimensions, dvdt, context->currentAcceleration);
}

static void derivative(int dimension,
                       double *ax,
                       double *bx,
                       double *cx,
                       double *dx,
                       double *output)
{
    addVectors(dimension, bx, cx, output);
    multiplyScalarWithVector(dimension, 2.0, output, output);
    addVectors(dimension, ax, output, output);
    addVectors(dimension, output, dx, output);
    multiplyScalarWithVector(dimension, (1.0/6.0), output, output);
}

static void evaluate(INTUSpringSolverContextRef context,
                     const double *positionVector,
                     const double *velocityVector,
                     double t,
                     double *deltaPosition,
                     double *deltaVelocity)
{
    copyVector(kINTUSpringSolverDimensions, velocityVector, deltaPosition);
    acceleration(context, positionVector, velocityVector, t, deltaVelocity);
}

static void evaluateWithDerivative(INTUSpringSolverContextRef context,
                                   const double *initialPositionVector,
                                   const double *initialVelocityVector,
                                   double t,
                                   double dt,
                                   const double *inputDeltaPosition,
                                   const double *inputDeltaVelocity,
                                   double *outputDeltaPosition,
                                   double *outputDeltaVelocity)
{
    double dpdt[kINTUSpringSolverDimensions], dvdt[kINTUSpringSolverDimensions];
    double positionVector[kINTUSpringSolverDimensions], velocityVector[kINTUSpringSolverDimensions];

    multiplyScalarWithVector(kINTUSpringSolverDimensions, dt, inputDeltaPosition, dpdt);
    multiplyScalarWithVector(kINTUSpringSolverDimensions, dt, inputDeltaVelocity, dvdt);

    addVectors(kINTUSpringSolverDimensions, initialPositionVector, dpdt, positionVector);
    addVectors(kINTUSpringSolverDimensions, initialVelocityVector, dvdt, velocityVector);

    copyVector(kINTUSpringSolverDimensions, velocityVector, outputDeltaPosition);
    acceleration(context, positionVector, velocityVector, t+dt, outputDeltaVelocity);
}

static void acceleration(const INTUSpringSolverContextRef context,
                         const double *positionVector,
                         const double *velocityVector,
                         double t,
                         double *accelerationVector)
{
    double intermediate1[kINTUSpringSolverDimensions], intermediate2[kINTUSpringSolverDimensions];

    multiplyScalarWithVector(kINTUSpringSolverDimensions, (-context->stiffness/context->mass), positionVector, intermediate1);
    multiplyScalarWithVector(kINTUSpringSolverDimensions, (context->damping/context->mass), velocityVector, intermediate2);

    subVectors(kINTUSpringSolverDimensions, intermediate1, intermediate2, accelerationVector);
}

static void interpolate(int dimension,
                        const double *previousPositionVector,
                        const double *previousVelocityVector,
                        const double *currentPositionVector,
                        const double *currentVelocityVector,
                        double alpha,
                        double *outputPositionVector,
                        double *outputVelocityVector)
{
    double currentPositionTimesAlpha[kINTUSpringSolverDimensions], currentVelocityTimesAlpha[kINTUSpringSolverDimensions];

    multiplyScalarWithVector(dimension, alpha, currentPositionVector, currentPositionTimesAlpha);
    multiplyScalarWithVector(dimension, alpha, currentVelocityVector, currentVelocityTimesAlpha);

    multiplyScalarWithVector(dimension, (1-alpha), previousPositionVector, outputPositionVector);
    multiplyScalarWithVector(dimension, (1-alpha), previousVelocityVector, outputVelocityVector);

    addVectors(dimension, currentPositionTimesAlpha, outputPositionVector, outputPositionVector);
    addVectors(dimension, currentVelocityTimesAlpha, outputVelocityVector, outputVelocityVector);
}


text:
/*
 * File:   main.cpp
 * Author: mindaugas
 *
 * Created on August 28, 2013, 9:57 PM
 */

#include <cstdlib>
#include <vector>
#include "../ARFF.h"
#include "../Statistics.h"
#include "../ShufleEnum.h"
#include <iostream>
#include "../DistanceMetrics.h"
#include "../ObjectMatrix.h"
#include "../MDS.h"
#include "../HPCMethod.h"
#include "../DimReductionMethod.h"
#include "../SMACOF.h"
#include "../SAMANN.h"
#include "../SMACOFZEIDEL.h"
#include "mpi.h"
#include "../Projection.h"
#include "../AdditionalMethods.h"
#include <sstream>
#include <fstream>
using namespace std;

int AdditionalMethods::PID;

void TestMessagePassing(int n, int k, const char* method)
{
	cout << method << ": testing if CPU No. 0 can receive messages from other CPUs" << endl;
	if (n == k + 1)
		cout << method << ": test passed." << endl;
	else
		cout << method << ": test FAILED!!!" <<endl;
}

void TestMessageSendingToDie(vector<int> cpu, vector<int> ans, const char* method)
{
	int n = cpu.size();
	bool answer = true;
	cout << method << ": testing if CPUs: ";
	for (int i = 0; i < n - 1; i++)
		cout << cpu.at(i) << ", ";
	cout << cpu.at(n - 1) << " received a message from CPU No. 0 to die." << endl;

	for (int i = 0; i < n; i++)
	{
		if (ans.at(i) != 1)
		{
			answer = false;
			break;
		}
	}

	if (answer == true)
		cout<< method << ": test passed." << endl;
	else
		cout<< method << ": test FAILED!!!" << endl;
}

void TestMessageSendingToSendMatrix (int cpu, int ans, const char* method)
{
	cout << method << ": testing if CPU No. " << cpu << " received a message to send back matrix Y." << endl;

	if (ans == 1)
		cout<< method << ": test passed." << endl;
	else
		cout<< method << ": test FAILED!!!" << endl;
}

void TestTheSendOfMatrix (ObjectMatrix X, ObjectMatrix Y, int cpu, const char* method)
{
	cout << method << ": testing if CPU No. 0 succesfully received matrix from CPU No. " << cpu << endl;
	if (X.getObjectCount() == Y.getObjectCount())
		cout << method << ": test passed." << endl;
	else
		cout << method << ": test FAILED!!!" << endl;
}

void TestProjectionMatrixDimmensions(ObjectMatrix X, ObjectMatrix Y, int d, int CPU, const char* method)
{
	bool answer = true;
	int mx = X.getObjectCount();
	int my = Y.getObjectCount();
	cout << method << ": testing if the projection matrix Y is a [" << mx << "x" << d << "] matrix." << endl;
	if (mx == my)
	{
		for (int i = 0; i < my; i++)
		{
			if (Y.getObjectAt(i).getFeatureCount() != d)
			{
				answer = false;
				break;
			}
		}
		if (answer == true)
			cout << method << ": test passed." << endl;
		else
			cout << method << ": test FAILED (the number of columns does not match the preffered one)." << endl;
	}
	else
		cout << method << ": test FAILED (the number of rows in matrix Y received from CPU No. " << CPU
                     << " does not match the number of rows in matrix X)." << endl;
}

void TestProjectionMatrix(ObjectMatrix Y[], int k, const char* method)
{
	bool answer = true;
	cout << method << ": testing if the projection matrixes Y are identical." << endl;
	int m = Y[0].getObjectCount();
	int n = Y[0].getObjectAt(0).getFeatureCount();
	for (int i = 1; i < k; i++)
	{
		if (Y[i].getObjectCount() != m)
		{
			answer = false;
			break;
		}
	}
	if (answer == false)
		cout << method << ": test FAILED (mismatch of the number of rows in matrixes Y). " << endl;
	else
	{
		for (int i = 0; i < m; i++)
		{
			for (int j = 0; j < n; j++)
			{
				for (int l = 0; l < k - 1; l++)
				{
					if (Y[l].getObjectAt(i).getFeatureAt(j) - Y[l + 1].getObjectAt(i).getFeatureAt(j) > 0.01)
					{
						answer = false;
						break;
					}
				}
				if (answer == false)
					break;
			}
			if (answer == false)
				break;
		}
		if (answer == true)
			cout << method << ": test passed." << endl;
		else
			cout << method << ": test FAILED!!!" << endl;
	}
}

int main(int argc, char** argv) {
    //ofstream file ("parallelMethodsTestingReport.txt");
    int numOfProcs, pid, send, min_rank = 0;
                                                // (pid) proceso ID
                                                // (send) pranesimas del Y siuntimo / nesiuntimo
                                                // (min_rank) proceso ID, apskaiciavusio maziausia paklaida
    ObjectMatrix Y;                             // projekcijos matrica
    double **receiveArray, **sendArray;         // gaunama ir siunciama Y matricos
    double epsilon;                             // skaiciavimu tikslumas
    int maxIter, d;                             // (maxIter) leistinas iteraciju kiekis, (d) mazinimo dimensija
    double *stressErrors;
    double receivedStress, min_stress = 0.0;

    epsilon = 0.001;
    maxIter = 100;
    d = 2;

    MPI::Init(argc, argv);
    pid = MPI::COMM_WORLD.Get_rank();
    AdditionalMethods::PID = pid;
    numOfProcs = MPI::COMM_WORLD.Get_size();
    MPI_Status status;

    const char* method = "SMACOF";

    SMACOF mthd (epsilon, maxIter, d);
    //SMACOFZEIDEL mthd (epsilon, maxIter, d, BUBLESORTDSC);
    //SMACOFZEIDEL mthd (epsilon, maxIter, d, BUBLESORTASC);
    //SMACOFZEIDEL mthd (epsilon, maxIter, d, RANDOM);
    //SAMANN mthd(70, 10, 10.0, maxIter);

    if (pid == 0)
    {
        if (numOfProcs == 1)
        {
            Y = mthd.getProjection();
            TestProjectionMatrixDimmensions(mthd.X, Y, d, 0, method);
        }
        else
        {
            stressErrors = new double[numOfProcs];
            Y = mthd.getProjection();
            int n = Y.getObjectCount();
            int m = Y.getObjectAt(0).getFeatureCount();
	    int k = 0;
	    vector<int> confirm;
	    vector<int> cpu;
	    int received_confirm = -1, confirm_to_send = -1;
            stressErrors[0] = mthd.getStress();
            for (int i = 1; i < numOfProcs; i++)
            {
                MPI_Recv(&receivedStress, 1, MPI_DOUBLE, i, MPI_ANY_TAG, MPI_COMM_WORLD, &status);  // priimama paklaida is kiekvieno proceso
                stressErrors[i] = receivedStress;
		k++;
            }

	    TestMessagePassing(numOfProcs, k, method);

            min_stress = stressErrors[0];
            for (int i = 1; i < numOfProcs; i++)
                if (stressErrors[i] < min_stress)
                {
                    min_stress = stressErrors[i];
                    min_rank = i;
                }

            if (min_rank == 0)  // jei maziausia paklaida tevinio proceso siunciamas pranesimas likusiems, kad savo Y nesiustu
            {
                send = 0;
		cpu.reserve(numOfProcs - 1);
                for (int i = 1; i < numOfProcs; i++)
		{
                    MPI_Send(&send, 1, MPI_INT, i, 0, MPI_COMM_WORLD);
		    cpu.push_back(i);
		}

		confirm.reserve(numOfProcs - 1);
		for (int i = 1; i < numOfProcs; i++)
		{
                    MPI_Recv(&received_confirm, 1, MPI_INT, i, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
		    confirm.push_back(received_confirm);
		}
		TestMessageSendingToDie(cpu, confirm, method);
            }
            else
            {
		cpu.reserve(numOfProcs - 2);
		confirm.reserve(numOfProcs - 2);
                for (int i = 1; i < numOfProcs; i++)
                    if (i == min_rank)
                    {
                        send = 1;
                        MPI_Send(&send, 1, MPI_INT, i, 0, MPI_COMM_WORLD);  // siunciamas pranesimas, kad atsiustu Y
                    }
                    else
                    {
                        send = 0;
                        MPI_Send(&send, 1, MPI_INT, i, 0, MPI_COMM_WORLD);  // siunciamas pranesimas, kad nesiustu Y
			cpu.push_back(i);
                    }

		for (int i = 1; i < numOfProcs; i++)
                    if (i != min_rank)
                    {
                        MPI_Recv(&received_confirm, 1, MPI_INT, i, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
		    	confirm.push_back(received_confirm);
                    }
                    else
                    {
                        MPI_Recv(&received_confirm, 1, MPI_INT, min_rank, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
                        confirm_to_send = received_confirm;
                    }

		TestMessageSendingToDie(cpu, confirm, method);
		TestMessageSendingToSendMatrix (min_rank, confirm_to_send, method);

                receiveArray = AdditionalMethods::Array2D(n, m);

                MPI_Recv(&(receiveArray[0][0]), m * n, MPI_DOUBLE, min_rank, MPI_ANY_TAG, MPI_COMM_WORLD, &status);   // priimama Y
                Y = AdditionalMethods::DoubleToObjectMatrix(receiveArray, n, m);
		TestTheSendOfMatrix (mthd.X, Y, min_rank, method);
		TestProjectionMatrixDimmensions(mthd.X, Y, d, min_rank, method);
            }
        }
    }
    else
    {
        Y = mthd.getProjection();
        double stress = mthd.getStress();
	int confirm = 0;
        MPI_Send(&stress, 1, MPI_DOUBLE, 0, pid, MPI_COMM_WORLD);  // siunciama paklaida teviniam procesui
        MPI_Recv(&send, 1, MPI_INT, 0, MPI_ANY_TAG, MPI_COMM_WORLD, &status);  // priimamas pranesimas ar siusti Y

        if (send == 1)          // siusti, jei send = 1, nesiusti, jei send = 0
        {
            int n = Y.getObjectCount();
            int m = Y.getObjectAt(0).getFeatureCount();
            sendArray = AdditionalMethods::Array2D(n, m);
            sendArray = AdditionalMethods::ObjectMatrixToDouble(Y);
	    confirm = 1;
	    MPI_Send(&confirm, 1, MPI_INT, 0, pid, MPI_COMM_WORLD);
            MPI_Send(&(sendArray[0][0]), m * n, MPI_DOUBLE, 0, pid, MPI_COMM_WORLD);  // siunciama Y
        }
	else if (send == 0)
	{
		confirm = 1;
		MPI_Send(&confirm, 1, MPI_INT, 0, pid, MPI_COMM_WORLD);
	}
    }

    MPI_Finalize();

    return 0;
}


text:
/*
 *  21.04.2004 Original verion. davagin@udm.ru.
 *-----------------------------------------------------------------------
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *----------------------------------------------------------------------
 */
package davaguine.jmac.prediction;

import davaguine.jmac.info.CompressionLevel;
import davaguine.jmac.tools.Globals;
import davaguine.jmac.tools.JMACException;
import davaguine.jmac.tools.RollBufferFastInt;
import davaguine.jmac.tools.ScaledFirstOrderFilter;

import java.util.Arrays;

/**
 * Author: Dmitry Vaguine
 * Date: 02.05.2004
 * Time: 13:08:34
 */
public class PredictorCompressNormal extends IPredictorCompress {
    private final static int WINDOW_BLOCKS = 512;

    public PredictorCompressNormal(int nCompressionLevel) {
        super(nCompressionLevel);
        if (nCompressionLevel == CompressionLevel.COMPRESSION_LEVEL_FAST) {
            m_pNNFilter = null;
            m_pNNFilter1 = null;
            m_pNNFilter2 = null;
        } else if (nCompressionLevel == CompressionLevel.COMPRESSION_LEVEL_NORMAL) {
            m_pNNFilter = new NNFilter16(11, Globals.MAC_VERSION_NUMBER);
            m_pNNFilter1 = null;
            m_pNNFilter2 = null;
        } else if (nCompressionLevel == CompressionLevel.COMPRESSION_LEVEL_HIGH) {
            m_pNNFilter = new NNFilter64(11, Globals.MAC_VERSION_NUMBER);
            m_pNNFilter1 = null;
            m_pNNFilter2 = null;
        } else if (nCompressionLevel == CompressionLevel.COMPRESSION_LEVEL_EXTRA_HIGH) {
            m_pNNFilter = new NNFilter256(13, Globals.MAC_VERSION_NUMBER);
            m_pNNFilter1 = new NNFilter32(10, Globals.MAC_VERSION_NUMBER);
            m_pNNFilter2 = null;
        } else if (nCompressionLevel == CompressionLevel.COMPRESSION_LEVEL_INSANE) {
            m_pNNFilter = new NNFilter1280(15, Globals.MAC_VERSION_NUMBER);
            m_pNNFilter1 = new NNFilter256(13, Globals.MAC_VERSION_NUMBER);
            m_pNNFilter2 = new NNFilter16(11, Globals.MAC_VERSION_NUMBER);
        } else {
            throw new JMACException("Unknown Compression Type");
        }
    }

    public int CompressValue(int nA, int nB) {
        // roll the buffers if necessary
        if (m_nCurrentIndex == WINDOW_BLOCKS) {
            m_rbPrediction.Roll();
            m_rbAdapt.Roll();
            m_nCurrentIndex = 0;
        }

        // stage 1: simple, non-adaptive order 1 prediction
        nA = m_Stage1FilterA.Compress(nA);
        nB = m_Stage1FilterB.Compress(nB);

        // stage 2: adaptive offset filter(s)
        int predictIndex = m_rbPrediction.index;
        m_rbPrediction.m_pData[predictIndex] = nA;
        m_rbPrediction.m_pData[predictIndex - 2] = m_rbPrediction.m_pData[predictIndex - 1] - m_rbPrediction.m_pData[predictIndex - 2];

        m_rbPrediction.m_pData[predictIndex - 5] = nB;
        m_rbPrediction.m_pData[predictIndex - 6] = m_rbPrediction.m_pData[predictIndex - 5] - m_rbPrediction.m_pData[predictIndex - 6];

        int nPredictionA = (m_rbPrediction.m_pData[predictIndex - 1] * m_aryM[8]) + (m_rbPrediction.m_pData[predictIndex - 2] * m_aryM[7]) + (m_rbPrediction.m_pData[predictIndex - 3] * m_aryM[6]) + (m_rbPrediction.m_pData[predictIndex - 4] * m_aryM[5]);
        int nPredictionB = (m_rbPrediction.m_pData[predictIndex - 5] * m_aryM[4]) + (m_rbPrediction.m_pData[predictIndex - 6] * m_aryM[3]) + (m_rbPrediction.m_pData[predictIndex - 7] * m_aryM[2]) + (m_rbPrediction.m_pData[predictIndex - 8] * m_aryM[1]) + (m_rbPrediction.m_pData[predictIndex - 9] * m_aryM[0]);

        int nOutput = nA - ((nPredictionA + (nPredictionB >> 1)) >> 10);

        // adapt
        int adaptIndex = m_rbAdapt.index;
        m_rbAdapt.m_pData[adaptIndex] = (m_rbPrediction.m_pData[predictIndex - 1] != 0) ? ((m_rbPrediction.m_pData[predictIndex - 1] >> 30) & 2) - 1 : 0;
        m_rbAdapt.m_pData[adaptIndex - 1] = (m_rbPrediction.m_pData[predictIndex - 2] != 0) ? ((m_rbPrediction.m_pData[predictIndex - 2] >> 30) & 2) - 1 : 0;
        m_rbAdapt.m_pData[adaptIndex - 4] = (m_rbPrediction.m_pData[predictIndex - 5] != 0) ? ((m_rbPrediction.m_pData[predictIndex - 5] >> 30) & 2) - 1 : 0;
        m_rbAdapt.m_pData[adaptIndex - 5] = (m_rbPrediction.m_pData[predictIndex - 6] != 0) ? ((m_rbPrediction.m_pData[predictIndex - 6] >> 30) & 2) - 1 : 0;

        if (nOutput > 0) {
            int indexM = 0;
            int indexA = adaptIndex - 8;
            m_aryM[indexM++] -= m_rbAdapt.m_pData[indexA++];
            m_aryM[indexM++] -= m_rbAdapt.m_pData[indexA++];
            m_aryM[indexM++] -= m_rbAdapt.m_pData[indexA++];
            m_aryM[indexM++] -= m_rbAdapt.m_pData[indexA++];
            m_aryM[indexM++] -= m_rbAdapt.m_pData[indexA++];
            m_aryM[indexM++] -= m_rbAdapt.m_pData[indexA++];
            m_aryM[indexM++] -= m_rbAdapt.m_pData[indexA++];
            m_aryM[indexM++] -= m_rbAdapt.m_pData[indexA++];
            m_aryM[indexM++] -= m_rbAdapt.m_pData[indexA++];
        } else if (nOutput < 0) {
            int indexM = 0;
            int indexA = adaptIndex - 8;
            m_aryM[indexM++] += m_rbAdapt.m_pData[indexA++];
            m_aryM[indexM++] += m_rbAdapt.m_pData[indexA++];
            m_aryM[indexM++] += m_rbAdapt.m_pData[indexA++];
            m_aryM[indexM++] += m_rbAdapt.m_pData[indexA++];
            m_aryM[indexM++] += m_rbAdapt.m_pData[indexA++];
            m_aryM[indexM++] += m_rbAdapt.m_pData[indexA++];
            m_aryM[indexM++] += m_rbAdapt.m_pData[indexA++];
            m_aryM[indexM++] += m_rbAdapt.m_pData[indexA++];
            m_aryM[indexM++] += m_rbAdapt.m_pData[indexA++];
        }

        // stage 3: NNFilters
        if (m_pNNFilter != null) {
            nOutput = m_pNNFilter.Compress(nOutput);

            if (m_pNNFilter1 != null) {
                nOutput = m_pNNFilter1.Compress(nOutput);

                if (m_pNNFilter2 != null)
                    nOutput = m_pNNFilter2.Compress(nOutput);
            }
        }

        m_rbPrediction.index++;
        m_rbAdapt.index++;
        m_nCurrentIndex++;

        return nOutput;
    }

    public void Flush() {
        if (m_pNNFilter != null) m_pNNFilter.Flush();
        if (m_pNNFilter1 != null) m_pNNFilter1.Flush();
        if (m_pNNFilter2 != null) m_pNNFilter2.Flush();

        m_rbPrediction.Flush();
        m_rbAdapt.Flush();
        m_Stage1FilterA.Flush();
        m_Stage1FilterB.Flush();

        Arrays.fill(m_aryM, 0);

        m_aryM[8] = 360;
        m_aryM[7] = 317;
        m_aryM[6] = -109;
        m_aryM[5] = 98;

        m_nCurrentIndex = 0;
    }

    // buffer information
    protected RollBufferFastInt m_rbPrediction = new RollBufferFastInt(WINDOW_BLOCKS, 10);
    protected RollBufferFastInt m_rbAdapt = new RollBufferFastInt(WINDOW_BLOCKS, 9);

    protected ScaledFirstOrderFilter m_Stage1FilterA = new ScaledFirstOrderFilter(31, 5);
    protected ScaledFirstOrderFilter m_Stage1FilterB = new ScaledFirstOrderFilter(31, 5);

    // adaption
    protected int[] m_aryM = new int[9];

    // other
    protected int m_nCurrentIndex;
    protected NNFilter m_pNNFilter;
    protected NNFilter m_pNNFilter1;
    protected NNFilter m_pNNFilter2;
}